Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf4eb01

Browse files
committed
(refactor): export AsyncLocalStorage as object
- will need to export more from here with TS, like an interface, so won't be able to `import * as` in the future- also give it a default export
1 parentb1afcd6 commitbf4eb01

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

‎src/asyncLocalStorage.js‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
exportfunctionclear(){
2-
returncallWithPromise(window.localStorage.clear)
3-
}
4-
5-
exportfunctiongetItem(key){
6-
returncallWithPromise(window.localStorage.getItem,key)
7-
}
8-
9-
exportfunctionremoveItem(key){
10-
returncallWithPromise(window.localStorage.removeItem,key)
11-
}
12-
13-
exportfunctionsetItem(key,value){
14-
returncallWithPromise(window.localStorage.setItem,key,value)
1+
exportconstAsyncLocalStorage={
2+
clear(){
3+
returncallWithPromise(window.localStorage.clear)
4+
},
5+
getItem(key){
6+
returncallWithPromise(window.localStorage.getItem,key)
7+
},
8+
removeItem(key){
9+
returncallWithPromise(window.localStorage.removeItem,key)
10+
},
11+
setItem(key,value){
12+
returncallWithPromise(window.localStorage.setItem,key,value)
13+
}
1514
}
1615

1716
functioncallWithPromise(func, ...args){
@@ -21,3 +20,5 @@ function callWithPromise (func, ...args) {
2120
returnPromise.reject(err)
2221
}
2322
}
23+
24+
exportdefaultAsyncLocalStorage

‎src/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{onSnapshot,applySnapshot}from'mobx-state-tree'
22

3-
import*asAsyncLocalStoragefrom'./asyncLocalStorage.js'
3+
importAsyncLocalStoragefrom'./asyncLocalStorage.js'
44

55
exportconstpersist=(name,store,options={})=>{
66
let{storage, jsonify, whitelist, blacklist}=options

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp