Open piernik opened 4 years ago
Can you provide an example repository and explain the issue more detailed?
I updated the example project including a key and a migration
Does that help you?
I had the same issue. The problem here is that you must use a state token or a string rather than pass in the StateModel
that you might use with the selector.
In other words:
NgxsModule.forRoot([
AccountSettingsState,
]),
Works for the NgxsModule
import. But it won't work for the plugin:
NgxsAsyncStoragePluginModule.forRoot(IonicAsyncStorageService, {
key: [
AccountSettingsState, // will not work
ACCOUNT_SETTING_STATE_TOKEN, // will work
]}),
Later update: My problem was that I was using a StateToken
for the name in the @State
decorator. This was not supported. When changing from a token to a regular string name, using the StateClass
worked as expected.
Also, I might add that if you are using a StateToken
as the name parameter, this won't work either. See #158 for a fix.
@nvahalik : Thanks for your inputs. We still couldn't manage to make the async storage work with keys, despite using the mentioned state tokens. Neither does it work when using just the state class within the "key" array. Can you maybe point us to the right direction? Thanks in advance!
App Module
NgxsAsyncStoragePluginModule.forRoot(CustomStateStorageClass,
{
key: [
// --- persistent ---
SOME_STATE_TOKEN,
State
const STATE_NAME = "someStateName";
export const SOME_STATE_TOKEN = new StateToken<SomeStateModel>(STATE_NAME);
const DEFAULT_STATE: SomeStateModel = {
someContent: []
};
@State<SomeStateModel>({
name: STATE_NAME,
defaults: DEFAULT_STATE,
})
PS: In CustomStateStorageClass we're using the Storage Module from Ionic, which is working perfectly fine when not using "key".
Hi Daniel,
We stopped using this plugin for now since it was causing too many issues. I am not able to provide any other feedback at this time.
On 2 Mar 2021, at 4:11, Daniel Mägerli wrote:
@nvahalik : Thanks for your inputs. We still couldn't manage to make the async storage work with keys, despite using the mentioned state tokens. Can you maybe point us to the right direction? Thanks in advance!
App Module
NgxsAsyncStoragePluginModule.forRoot(CustomStateStorageClass, { key: [ // --- persistent --- SOME_STATE_TOKEN,
State
const STATE_NAME = "someStateName"; export const SOME_STATE_TOKEN = new StateToken<SomeStateModel>(STATE_NAME); const DEFAULT_STATE: SomeStateModel = { someContent: [] }; @State<SomeStateModel>({ name: STATE_NAME, defaults: DEFAULT_STATE, })
PS: In CustomStateStorageClass we're using the Storage Module from Ionic, which is working perfectly fine when not using "key".
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/ngxs-labs/async-storage-plugin/issues/123#issuecomment-788791027
I think that key option is not working.