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

Implement hoodie.reset() #12

Closed
1 task
gr2m opened this issue Nov 19, 2015 · 12 comments
Closed
1 task

Implement hoodie.reset() #12

gr2m opened this issue Nov 19, 2015 · 12 comments

Comments

@gr2m
Copy link
Member

gr2m commented Nov 19, 2015

Reset hoodie client and emit reset events so plugins can reset as well. Should implement a way so that plugins can hook into the reset with async operations

hoodie.reset().then(function () {
  // clean slate again
})

And plugins could do something like

hoodie.on('reset', function (options) {
  options.promise = options.promise.then(function () {
    // do some async reset here
  })
})

^^ This is just a suggestion, maybe there are better patterns for it :)

  • Update README as part of PR
@danreeves
Copy link
Contributor

Hi 👋

I'm gunna try to make a PR for this tonight. Sound good?

@gr2m
Copy link
Member Author

gr2m commented Dec 2, 2015

Sounds amazing :) All yours

@gr2m
Copy link
Member Author

gr2m commented Dec 11, 2015

Hey @danreeves what’s status?

@gr2m gr2m added in progress and removed ready labels Dec 11, 2015
@danreeves
Copy link
Contributor

Hi @gr2m, finally had some time to look at this tonight. I've had some issues getting hoodie@next and hoodie-client working together but that's maybe another issue. I've made a WIP PR here: #32

Looking like the right direction?

@gr2m
Copy link
Member Author

gr2m commented Dec 13, 2015

Awesome I'll check it out tomorrow, thanks a ton!

@Guria
Copy link

Guria commented Dec 21, 2015

@gr2m I am not guru in api design, but options.promise = options.promise.then looks ugly for me. can't we just return promise and manage it from callback caller instead?

@gr2m
Copy link
Member Author

gr2m commented Dec 21, 2015

Yeah I’m wondering if there is a nicer API :) But the one with options.promise is the best shot right now, as we can’t get the value that is returned by event handlers

hoodie.on('reset', function () {
  return new Promise(...) // this goes nowhere
})

hoodie.trigger('reset')

@gr2m gr2m mentioned this issue Jan 6, 2016
@gr2m
Copy link
Member Author

gr2m commented Jan 6, 2016

@Guria here’s an alternative API suggestion to intercept things like reset events: #42

@danreeves
Copy link
Contributor

@gr2m looks similar to something I was working on to get the .reset() call to be thenable without racing the event listeners: danreeves@9ded20e

edit: because options.promise = options.promise.then didn't appear to be working as expected

@gr2m
Copy link
Member Author

gr2m commented Jan 7, 2016

@danreeves clever!!

@gr2m
Copy link
Member Author

gr2m commented Jan 7, 2016

@danreeves let’s put hoodie.reset on hold for now. We have to think about the hooks as we need it for the glue code between hoodie.store and hoodie.account, but hoodie.reset only becomes relevant with plugins which we put out of scope for the first release. I like your options.hooks idea, maybe we can use that implementation for the hooks in sign in / sign out

@danreeves
Copy link
Contributor

Yeah, that makes sense

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

3 participants