Comments (9)
No problem. Sorry I don't have that feature now. I doubt it'll ever be in the core package but could potentially be an add-on package some day.
from observable-store.
If you can put a Stackblitz (https://stackblitz.up) demo together that demonstrates your issue I'm happy to look into it more. We use setState all the time without any issues so I'd need a demo that reproduces what you're seeing.
from observable-store.
If you can put a Stackblitz (https://stackblitz.up) demo together that demonstrates your issue I'm happy to look into it more. We use setState all the time without any issues so I'd need a demo that reproduces what you're seeing.
okay, btw I have another problem would you take a look at it
Is there a way to use the state of a class in a synchronous way because there is a limitation in some places in angular for using asynchronous value and we should provide the data with synchronous methods for instance we should provide such thing in interceptors, I tried to get rid of state asynchronous behavior with a trick but it didn't work
I created a method in my state class and I tend to call it in other places but it always returns the default value!!!
plz help to overcome this issue
public getUserState(): UserState | null {
const state = this.getState();
console.log('state in auth service', state);
if (state && state.currentUser) {
return state;
}
return null;
}
FYI @DanWahlin
from observable-store.
Calling getState() should always return the latest state value. Based on what you're saying here and the other issue you mention I suspect something else is going on. Once you can put together a demo to reproduce the issue I'll take a look as soon as I can.
I'd also run the supplied demos if you haven't already because they show setState and getState working correctly.
from observable-store.
@DanWahlin
I tried all the stuff in an experimental project and setState worked but I dunno why it loses it's when I'm reloading the page!!
plz check this link
https://stackblitz.com/edit/angular-ivy-icrmc4?file=src/index.html
btw I recorded a video from my local machine hope it help you for understanding my issue
ObservableStore.mp4
from observable-store.
I wish everyone was as detailed as that. Thank you...that helps. 😀
Observable Store is a client side only state management solution. All state is stored in memory so if the app is reloaded in the browser all of your state is reinitialized again. That's normal for these types of client state solutions. It's used to manage state while the app is running but isn't designed to store state across user sessions as mentioned.
If you want the state to be stored across page loads (refreshes for example) you'll have to handle that part yourself and then pass that saved state to Observable Store when the app first loads. State for a user could be stored in localStorage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) for example. If the state needs to be stored for a user to access anywhere, then you'd have to pass the state to an API which then handles storing it in some type of database or other store.
from observable-store.
@DanWahlin Thank you for the description.
but I think if the package has an option for storing data in local or session storage it would be nice
because sharing data in the whole application is possible with normal observable and saving data in a store like local storage and manage by this package would be kinda added value
from observable-store.
Thanks. That's something I'll consider for future releases. The challenge is that there are limitations on localStorage size, security challenges that can come up and more (that's why most state management solutions don't handle that out of the box). Right now it's not something I'm planning to build, but I'll add it to the list for consideration in the future. I appreciate your feedback.
from observable-store.
Thank you @DanWahlin I confess that you reply very quickly and it was very awesome for me!
hope to provide that part for the package very soon
from observable-store.
Related Issues (20)
- Replay Subject for edge cases HOT 4
- Why won't a getter from a service/state work after any store changes? HOT 6
- Missing properties after setting state HOT 8
- Weird store structure when using stateSliceSelector HOT 2
- Store structure: Flat vs Complex + stateWithPropertyChanges returns function if that's what was passed in the setState HOT 1
- This lib can be performance problems HOT 1
- It would help so much if you included a fully working react example HOT 2
- Using state in synchronous manner HOT 1
- Rx.js 7.2 migration and compatibility? HOT 4
- Using JSONPath and Observable store HOT 4
- Setting State via SetState for one property HOT 4
- CommonJS or AMD dependencies can cause optimization bailouts. HOT 3
- How can I access the Observable-store data through the `window` object? HOT 3
- Is it necessary to deep clone the state when dispatching? HOT 7
- Problem with ReduxDevToolsExtension under electron environment HOT 5
- Losing Class (getters/setters) when returning object from store HOT 1
- setState() does not update property when setting to undefined HOT 1
- How to store n number of propertes (making the state properties dynamic) HOT 1
- is it possible to filter by Action? 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 observable-store.