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

Add .then() method #8

Closed
wants to merge 2 commits into from
Closed

Add .then() method #8

wants to merge 2 commits into from

Conversation

alexlafroscia
Copy link
Contributor

Added the .then() method to the Chain that Mark and I had talked about at MHacks. It is to be used to execute an arbitrary callback after the loading/changing of some data has been completed.

I would really like to be able to have .then() only run the callback once .map() has finished iterating over its values, since I think that makes a lot more sense in the context of what you'd want to do with .then(). However, I'm not sure how to implement something like that. Mark seemed to have some ideas, though.

Added the .then() method to the Chain that Mark and I had talked about at MHacks.  It is to be used to execute an arbitrary callback after the loading/changing of some data has been completed.

I would really like to be able to have .then() only run the callback once .map() has finished iterating over its values, since I think that makes a lot more sense in the context of what you'd want to do with .then().  However, I'm not sure how to implement something like that.  Mark seemed to have some ideas, though.
I had used .skip on a failing test, which made no sense.  It should be left
failing until we make the API do what we want it to do.
@amark
Copy link
Owner

amark commented Jan 21, 2015

From gitter.im, yeah I'll try working on more tests, getting a .done() method (which will be more userful than .then()) and style guidelines/more documentation up tonight and the following nights.

@alexlafroscia
Copy link
Contributor Author

👍

@amark
Copy link
Owner

amark commented Jan 23, 2015

So maybe I should just document the internal then works, and then done is probably going to be more of a plugin.

so if you were to create an extension, using internal then:

var Gun = Gun || require('gun'); // both
Gun.chain.then = function(cb){
  var this = gun;
  gun.shot.then(function(){ // internal
    cb(); // your code or logic here!
  });
  return gun; 
}

The only issue with the internal technique, is gun doesn't actually pass anything in the parameters, everything is done by references on gun._ which probably shouldn't be touched unless you know what you are doing (which is fine, people should feel encouraged that they do know, just as long as tests still pass + that also means I should document stuff better, even for internal use).

@sylvia43
Copy link

Does that mean we can close this PR?

@amark amark closed this Jan 28, 2015
@metasean metasean deleted the add-then-method branch June 11, 2015 22:52
amark pushed a commit that referenced this pull request Jan 9, 2020
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

Successfully merging this pull request may close these issues.

3 participants