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

Add adapter utility functions #41

Merged
merged 4 commits into from
Jan 28, 2023
Merged

Add adapter utility functions #41

merged 4 commits into from
Jan 28, 2023

Conversation

yumauri
Copy link
Owner

@yumauri yumauri commented Jan 28, 2023

Addresses issue #35

This PR adds two changes:

  1. Separates terms "supported" and "available" for adapters

Previously, if localStorage was disabled by browser's security policies, local adapter just did nothing. like localStorage doesn't exists.

Now, local adapter separates cases, when localStorage is not supported (not exists, for example, in Node environment), then adapter does nothing. And when localStorage is supported (exists), but disabled by security policies — adapter will trigger errors on each read/write operation. Errors could be handled by fail event, as usual.

This is breaking change.

  1. Adds either utility function

Given two adapters, this function will return first one, either second one, if first one is "no-op" adapter, meaning "not supported" / "does nothing". For example, nil adapter is no-op adapter. local adapter in Node environment is no-op adapter.

@yumauri yumauri merged commit 264c58f into master Jan 28, 2023
@yumauri yumauri deleted the fallback_adapter branch January 28, 2023 13:33
@yumauri yumauri added this to the 6.0.0 milestone Jan 28, 2023
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

Successfully merging this pull request may close these issues.

1 participant