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

Support loopback.getCurrentContext in the browser #1020

Closed
BerkeleyTrue opened this issue Jan 19, 2015 · 4 comments
Closed

Support loopback.getCurrentContext in the browser #1020

BerkeleyTrue opened this issue Jan 19, 2015 · 4 comments

Comments

@BerkeleyTrue
Copy link
Contributor

This would help with things like storing user sessions and access token in localStorage while using an existing api.

// server

var ctx = loopback.getCurrentContext();

ctx.set('currentUser', user); // Uses continuous-local-storage and domains

// client

var  ctx = loopback.getCurrentContext();

ctx.set('currentUser', user); // Uses localStorage 
@ritch
Copy link
Member

ritch commented Jan 31, 2015

+1

Although I am a bit worried about building on top of getCurrentContext(). It is very slow...

@bajtos
Copy link
Member

bajtos commented Feb 17, 2015

I don't like this idea:

  • LocalStorage is persistent, the "current context" is not meant to be persisted.
  • When there are two methods called in parallel, each invocation has it's own "current context". LocalStorage-backed "current context" would be shared by all invocations.

We should find a different way how to provide "current context" functionality in a browser.

@bajtos bajtos changed the title Extend loopback context to work with localStorage in the client. Support loopback.getCurrentContext in the browser Feb 17, 2015
@bajtos bajtos added the browser label Feb 17, 2015
@bajtos
Copy link
Member

bajtos commented Feb 24, 2015

We should get this for free once othiym23/async-listener#14 is implemented and released.

@pthieu
Copy link

pthieu commented Nov 3, 2016

Closing in favour of othiym23/async-listener#14.

Please re-open if this is still required ands separate from above link., @BerkeleyTrue.

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

5 participants