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

Following multiple link relations from a resource. #11

Closed
patrickjuchli opened this issue May 4, 2015 · 3 comments
Closed

Following multiple link relations from a resource. #11

patrickjuchli opened this issue May 4, 2015 · 3 comments

Comments

@patrickjuchli
Copy link

In vanilla traverson, I've been successfully using traversal.continue() to follow multiple link relations from a resource.

I have problems doing the same thing with traverson-angular. I'm following the documentation on traverson-angular for continuing a link traversal but I get stuck when I try to create two different continuations from an initial request.

Am I doing something wrong with cloning the request builder? Following the documentation:

   request.continue().then(function(request) {
       request.follow("my-resource")
       ...

This works as expected. As a next step, I want to clone the request builder with newRequest() in order two launch two seperate requests based on the initial one:

   request.continue().then(function(request) {
        var clonedRequest = request.newRequest();
        clonedRequest.follow("my-resource")
        ...

This is not working, what am I missing?

@patrickjuchli
Copy link
Author

Update:
Looking at clonedRequest above, its property continuation is null. Copying the continuation property of the request over to clonedRequest makes everything work as expected:

request.continue().then(function(request) {
     var branch1 = request.newRequest();
     var branch2 = request.newRequest();
     branch1.continuation = request.continuation;
     branch2.continuation = request.continuation;

     branch1.follow("my-nested-resource")
     ...

     branch2.follow("my-other-nested-resource")
     ...

Works. Is this a possible bug fix?

@basti1302
Copy link
Member

Yeah, right. Seems I promised too much regarding the combination of continue() and newRequest() in the docs without testing it :-(

I wonder why this worked for you in vanilla traverson? Or didn't you use newRequest() on the continued traversal when testing with vanilla? Because for me, it looks like this was broken in traverson already.

Anyway, a fix landed in traverson@2.0.1 and traverson-angular@2.1.2 includes traverson@2.0.1, so it also has this fix.

@patrickjuchli
Copy link
Author

You are right, I wasn't using newRequest() at all when you using plain traverson. Somehow it still worked just using traversal.continue().follow... multiple times. Well, at least I now learned how to use Traverson correctly. Thanks a lot for the fix!

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

No branches or pull requests

2 participants