webext-storage
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -10,2 +10,4 @@ /// <reference types="chrome" /> | ||
readonly defaultValue?: Default; | ||
/** @deprecated Use `onChanged` instead */ | ||
onChange: (callback: (value: NonNullable<Default>) => void, signal?: AbortSignal) => void; | ||
constructor(key: string, { area, defaultValue, }?: StorageItemOptions<NonNullable<Default>>); | ||
@@ -15,3 +17,3 @@ get: () => Promise<Return>; | ||
remove: () => Promise<void>; | ||
onChange(callback: (value: NonNullable<Default>) => void, signal?: AbortSignal): void; | ||
onChanged(callback: (value: NonNullable<Default>) => void, signal?: AbortSignal): void; | ||
} |
@@ -6,2 +6,4 @@ import chromeP from 'webext-polyfill-kinda'; | ||
defaultValue; | ||
/** @deprecated Use `onChanged` instead */ | ||
onChange = this.onChanged; | ||
constructor(key, { area = 'local', defaultValue, } = {}) { | ||
@@ -26,3 +28,3 @@ this.key = key; | ||
}; | ||
onChange(callback, signal) { | ||
onChanged(callback, signal) { | ||
const changeHandler = (changes, area) => { | ||
@@ -29,0 +31,0 @@ const changedItem = changes[this.key]; |
{ | ||
"name": "webext-storage", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "A more usable typed storage API for Web Extensions", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -32,3 +32,3 @@ # webext-storage [![][badge-gzip]][link-bundlephobia] | ||
await options.set({color: 'red'}) // Type-checked | ||
options.onChange(newValue => { | ||
options.onChanged(newValue => { | ||
console.log('New options', newValue) | ||
@@ -44,3 +44,3 @@ }); | ||
- If you provide a `defaultValue`, the return type will not be ` | undefined` | ||
- The `onChange` example speaks for itself | ||
- The `onChanged` example speaks for itself | ||
@@ -76,3 +76,3 @@ ## Install | ||
username.onChange(newName => { | ||
username.onChanged(newName => { | ||
console.log('The user’s new name is', newName); | ||
@@ -79,0 +79,0 @@ }); |
8113
59