Skip to content

Commit

Permalink
fix: broken export for registerStore
Browse files Browse the repository at this point in the history
  • Loading branch information
euaaaio committed May 12, 2023
1 parent 51584c7 commit f0f091e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
8 changes: 0 additions & 8 deletions devtools/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,3 @@ export function attachStores(
nameGetter?: StoreNameGetter
}
): void

/**
* Registers the store for the component inspector
*
* @param store Any store
* @private
*/
export function registerStore(store: AnyStore): void
10 changes: 0 additions & 10 deletions devtools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
onSet
} from 'nanostores'
import { setupDevtoolsPlugin } from '@vue/devtools-api'
import { getCurrentInstance } from 'vue'

const layerId = 'nanostores'
const inspectorId = 'nanostores'
Expand Down Expand Up @@ -397,12 +396,3 @@ export function attachStores(app, stores, opts = {}) {
})
})
}

export function registerStore(store) {
let instance = getCurrentInstance()
if (instance && instance.proxy) {
let vm = instance.proxy
let cache = '_nanostores' in vm ? vm._nanostores : (vm._nanostores = [])
cache.push(store)
}
}
12 changes: 10 additions & 2 deletions use-store/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ import { Store, StoreValue } from 'nanostores'
* </script>
* ```
*
* @param store Store instance.
* @returns Store value.
* @param store Store instance
* @returns Store value
*/
export function useStore<
SomeStore extends Store,
Value extends StoreValue<SomeStore>
>(store: SomeStore): DeepReadonly<Ref<Value>>

/**
* Registers the store for the devtools component inspector.
*
* @param store Store instance
* @private
*/
export function registerStore(store: AnyStore): void
17 changes: 15 additions & 2 deletions use-store/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { getCurrentScope, onScopeDispose, readonly, shallowRef } from 'vue'
import {
getCurrentInstance,
getCurrentScope,
onScopeDispose,
readonly,
shallowRef
} from 'vue'

import { registerStore } from '../devtools/index.js'
export function registerStore(store) {
let instance = getCurrentInstance()
if (instance && instance.proxy) {
let vm = instance.proxy
let cache = '_nanostores' in vm ? vm._nanostores : (vm._nanostores = [])
cache.push(store)
}
}

export function useStore(store) {
let state = shallowRef()
Expand Down

0 comments on commit f0f091e

Please sign in to comment.