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 States within the key parameter #157

Closed
nvahalik opened this issue Aug 5, 2020 · 5 comments
Closed

Support States within the key parameter #157

nvahalik opened this issue Aug 5, 2020 · 5 comments

Comments

@nvahalik
Copy link

nvahalik commented Aug 5, 2020

Currently the key option for the importing of the plugin only allows for State Tokens and strings. This causes an error (#123) if you pass in a StateModel.

It should be fairly easy to suppose a StateModel object since it has a name attribute which is the value that needs to be examined rather than the key itself.

for (const key of keys) {
    let val = nextState;
    if (key !== '@@STATE') {
        val = getValue(nextState, key);
    }
    try {
        this._asyncEngine.setItem(key, options.serialize(val));
    }
    catch (e) {
        console.error('Error ocurred while serializing the store value, value not updated.');
    }
}

Just check to see if the key is a StateModel and if it is, the "real name" is key.name rather than key.

@marcjulian
Copy link
Collaborator

@nvahalik do you mind creating a PR for this issue?

@nvahalik
Copy link
Author

@marcjulian Sure. I'm working on it now.

Looks like this should already work based on how it's configured. It doesn't really make sense, but perhaps the issue here is a build problem and not a code problem?

When I use my locally built version of the plugin, using a StateModel works as expected. However, upon switching back to the latest release, it fails. The failure is in the transformKeyOption function:

My Transphormation Starts Today 2020-08-11 09-54-42

It reports that StateModel is undefined.

I'm unfamiliar enough with how these modules are built to know where to go from here.

@nvahalik
Copy link
Author

The above was tested w/ Firefox 79 and the project is being used with the IonicAsyncStorageService driver (um, copy-pasted from the repo...) on an Ionic 4 project using Angular 7.

@nvahalik
Copy link
Author

Ah, OK. I figured out what was going on. PR submitted! #158

@nvahalik
Copy link
Author

Note that I was still having problems with using StateToken directly in the key list, but this appears to be some sort of AoT issue and not related to any bug in this plugin. I will close out this ticket.

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

2 participants