functionsetup() { if (!initialState && (!__DEV__ || !hot)) { /* istanbul ignore if */ pinia.state.value[id] = state ? state() : {} }
// avoid creating a state in pinia.state.value const localState = __DEV__ && hot ? // use ref() to unwrap refs inside state TODO: check if this is still necessary toRefs(ref(state ? state() : {}).value) : toRefs(pinia.state.value[id])
returnassign( localState, actions, Object.keys(getters || {}).reduce( (computedGetters, name) => { if (__DEV__ && name in localState) { console.warn( `[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".` ) }
computedGetters[name] = markRaw( computed(() => { setActivePinia(pinia) // it was created just before const store = pinia._s.get(id)!
// allow cross using stores
// @ts-expect-error // return getters![name].call(context, context) // TODO: avoid reading the getter while assigning with a global variable return getters![name].call(store, store) }) ) return computedGetters }, {} asRecord<string, ComputedRef> ) ) }
store = createSetupStore(id, setup, options, pinia, hot, true)
pinia.state.value const localState = __DEV__ && hot ? // use ref() to unwrap refs inside state TODO: check if this is still necessary toRefs(ref(state ? state() : {}).value) : t : t
Object.keys(getters || {}).reduce( (computedGetters, name) => { if (__DEV__ && name in localState) { console.warn( `[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".` ) }
computedGetters[name] = markRaw( computed(() => { setActivePinia(pinia) // it was created just before const store = pinia._s.get(id)!
// allow cross using stores
// @ts-expect-error // return getters![name].call(context, context) // TODO: avoid reading the getter while assigning with a global variable return getters![name].call(store, store) }) ) return computedGetters }, {} asRecord<string, ComputedRef> )