Code Monkey home page Code Monkey logo

Comments (3)

ericbottard avatar ericbottard commented on July 19, 2024

+1
Would be interested in seeing support/thoughts on this.
Restangular is more flexible than ngResource for this kind of approach, but I guess dedicated instructions would be welcome

from restangular.

mgonto avatar mgonto commented on July 19, 2024

Hey,

I'm not planning on implementing HAL right now. I might be able to implement it on the future.

Anyway, it wouldn't be that hard to implement it. I can give you some tips and then you can create a Pull Request with this implemented and I'll add it to the current codebase.

Restangular supports setting a UrlCreator. That URLCreator will be the one who has to take care about creating the URL to call depending on the tree.

Check https://github.com/mgonto/restangular/blob/master/src/restangular.js#L139

You can create your own implementation of URLCreator using the base prototype from BaseCreator. With that you can configure creating URLs based on __link.

Then, regarding embed resources, I think that they should be "inner" Restangularized objects. So, what I'd do is to add a Hook to this URLCreator (and maybe rename it RestStrategy) which will be called after some element has been received and restangularized. After that, I think that you can actually check the tree for that object and if you find some embedable resource, then you can restangularize it (Removing that __link boilperplate and adding it as metadata to to the object for creating the URL only), and then return the "processed" tree with only ojects and no metadata. Metadata will be there in the form of properties or functions (like other Restangular stuff), but wouldn't be in the way of the real model information.

Does this make sense?

from restangular.

mgonto avatar mgonto commented on July 19, 2024

Closing this one and continuing discussion in Making URLCreator issue.

from restangular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.