Comments (8)
@heartsentwined How about using session.destroy()
then recreating it on the container.
session.destroy();
container.unregister('session:main');
container.register('session:main', App.DefaultSession || Ep.Session);
I'm still figuring out Epf, not sure this is the right way.
from epf.
Folks over at ember-data recommended a similar solution too, but got rejected by the devs on grounds that
we actually pass the store reference around and those references would not be updated. We probably should have a method to do this.
Would love to hear from @ghempton on this suggestion.
from epf.
This is a good question. Creating a new top-level session (e.g. adapter.newSession()
) is the answer I want to give, but alas the ember-data folks are correct that the injected references will not be updated.
If we want the references to be updated, a higher level approach needs to be taken and all the controllers and routes need to be re-created. Perhaps the entire application could be reset using Application.reset()
?
Alternatively, it would be fairly straightforward to create an api such as session.unload()
, but that seems kind of fragile for this use case. Thoughts?
from epf.
I haven't dug deep yet, but from the observed behavior it seems that load()
, find()
, and friends (if any) does this:
- if the passed tuple of
ModelClass
+id
is present in cache, return it immediately - otherwise query the server for it
So I think that the unload()
api can simply clear the cache, and mark all tuples as unseen. This will allow you to maintain the same reference to the session. However, I am not sure if there are other traces unique to the current session that ought to be cleared.
An Application.reset()
is as unattractive as the forced-refresh workaround. Say Alice is looking at a dress, and urges her friend Cindy to buy it. Alas, Alice needs to log out so that Cindy can log into her account. The refresh / app-reset approach will clear everything, then try to reload it from the URL (and maybe cookies) alone. Granted, a well-designed app should be able to do that, although it will quickly get tedious to keep track of, say, the "yellow" color checkbox right next to the dress. Not to mention that the page goes "unresponsive" for a while (waiting for server to confirm log out success), then goes "blank" (refresh), and yet more wait time for the app-reload. If possible I would prefer to keep the ember app in place, and just let the little sign in/out box at the corner does its magic without interrupting Cindy's gaze at the beautiful dress. A customer!
from epf.
As discyssion over at the ember-data thread has mentioned, Application.reset()
is good for unit-testing though. However, it's even better to destroy()
everything - so that already takes care of this use case IMO.
from epf.
I'm for adding an unload
method. It shouldn't be too hard, short of a few edge cases. Will mark this issue as a feature request for it. This will also suffer from dangling references to unloaded models, however.
I can't help but wish it were easier to swap out session instances as this use case seems perfect for it. I wonder if there are some optimizations that can be done around App.reset
(e.g. keeping the models around and manually adding to the session).
from epf.
from epf.
from epf.
Related Issues (20)
- Ep.IdSerializer can break with mongodb HOT 3
- typeKey seems incompatible with non-global Ember HOT 1
- Epf conflict with Ember.SimpleAuth HOT 6
- stricter jqXHR check
- Add `session.persist` HOT 1
- Testing EPF on ember-cli? HOT 6
- how to handle server error 500 on Model.find?
- Slow performance with 100 children HOT 5
- Using with ember-cli? HOT 6
- Still Alive? HOT 2
- Question: Embedded Documents HOT 24
- Embedded Update Error HOT 20
- Must be attached to a session. HOT 3
- Can't build distributable HOT 2
- Sideloading? HOT 6
- api documentation HOT 1
- Can't have belongsTo relation to work... HOT 2
- Delete parent model instance update children HOT 3
- Offline / network issues?
- Is the project dead? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from epf.