chore(lib/storage): move Storage#use initialization back to library
This commit is contained in:
parent
333ba5622e
commit
d386035342
5 changed files with 6 additions and 5 deletions
|
|
@ -6,6 +6,9 @@
|
|||
".": {
|
||||
"default": "./src/index.ts"
|
||||
},
|
||||
"./init": {
|
||||
"default": "./src/init.ts"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./src/types.ts"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export function Storage<T extends AnyObject>(
|
|||
}
|
||||
|
||||
// React is only initialized right before the init stage, so this is a dummy method
|
||||
// See define-storage-use.ts in api.storage plugin for the actual implementation
|
||||
// See init.ts in api.storage plugin for the actual implementation
|
||||
Storage.prototype.use = () => {
|
||||
throw new Error('Storage#use can only be called after the init stage!')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import { useEffect } from 'react'
|
|||
import type { StorageSubscription } from '@revenge-mod/storage'
|
||||
|
||||
// Actual implementation of Storage#use
|
||||
const SP: Storage<any> = Storage.prototype
|
||||
SP.use = function (filter) {
|
||||
;(Storage.prototype as Storage<any>).use = function (filter) {
|
||||
if (!this.cache) this.get()
|
||||
|
||||
const reRender = useReRender()
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
// Initialize init libraries
|
||||
import '@revenge-mod/react/init'
|
||||
import '@revenge-mod/storage/init'
|
||||
|
||||
import { onRunApplication } from '@revenge-mod/react/native'
|
||||
import { onError } from './preinit'
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ registerPlugin(
|
|||
})
|
||||
},
|
||||
init({ decorate }) {
|
||||
require('./define-storage-use')
|
||||
|
||||
decorate(plugin => {
|
||||
defineLazyProperty(plugin.api, 'storage', () =>
|
||||
getStorage(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue