Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide deep linking down the entity chain #16

Closed
gxxcastillo opened this issue Apr 15, 2013 · 4 comments
Closed

Provide deep linking down the entity chain #16

gxxcastillo opened this issue Apr 15, 2013 · 4 comments
Labels

Comments

@gxxcastillo
Copy link
Contributor

Following up on Kevin's comments in this thread: #15

...and as mentioned in this twitter thread: https://twitter.com/dhh/status/281779048978472960 and in this post: http://37signals.com/svn/posts/3373-getting-hyper-about-hypermedia-apis

We need some kind of deep linking.

I still need to figure out how to define the api for this but the idea is you should be able to do:

getSomeEntity('baseEntity#nestedEntityName#anotherNestedEntityName');

The idea behind the '#' is to be somewhat similar to css selectors. Eventually, if we want to support selecting by "class" we might want to do something like:

getSomeEntity('baseEntity.someClassName');

...just for now...yet to see how it can work out...

@apsoto
Copy link
Contributor

apsoto commented Apr 15, 2013

I don't think multiple hashes is valid syntax.

@gxxcastillo
Copy link
Contributor Author

Yeah, apologies for the misleading verbiage, while deep linking via a url hash would be invalid I was thinking of something more similar to a CSS selector. (only we are using "name" instead of "id")

@gxxcastillo
Copy link
Contributor Author

I've got this mostly coded up. There are two functions:

A static function, Backbone.Siren.resolveChain() and an instance method, instance.resolveChain(). Both take a "selector" string like the one mentioned above (to avoid any confusion, I'm referring to this selector string as a "chain" from now on). Both also return a jQuery promise that resolves with the last descendant in the "chain" as the argument to all callbacks.

I'm open to ideas on better syntax for the "chains". I'm also wondering if maybe it makes sense to have the argument to all promise callbacks be the root level object as apposed to the last descendant...?

Code should be in shortly...

@gxxcastillo
Copy link
Contributor Author

Closing this out. It's currently functional via `Backbone.Siren.resolve()' and while it needs additional work, I'll file that under a separate ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants