fix: override client context store on create
This commit is contained in:
parent
4d56b4873c
commit
cacd735961
|
@ -11,6 +11,7 @@ const contextStoreKey = (dataProviderId, childIndex) =>
|
||||||
`${dataProviderId}${childIndex >= 0 ? ":" + childIndex : ""}`
|
`${dataProviderId}${childIndex >= 0 ? ":" + childIndex : ""}`
|
||||||
|
|
||||||
// creates a store for a datacontext (e.g. each item in a list component)
|
// creates a store for a datacontext (e.g. each item in a list component)
|
||||||
|
// overrides store if already exists
|
||||||
const create = (data, dataProviderId, childIndex, parentContextStoreId) => {
|
const create = (data, dataProviderId, childIndex, parentContextStoreId) => {
|
||||||
const key = contextStoreKey(dataProviderId, childIndex)
|
const key = contextStoreKey(dataProviderId, childIndex)
|
||||||
const state = { data }
|
const state = { data }
|
||||||
|
@ -22,14 +23,13 @@ const create = (data, dataProviderId, childIndex, parentContextStoreId) => {
|
||||||
? contextStores[parentContextStoreId].state
|
? contextStores[parentContextStoreId].state
|
||||||
: rootState
|
: rootState
|
||||||
|
|
||||||
if (!contextStores[key]) {
|
contextStores[key] = {
|
||||||
contextStores[key] = {
|
store: writable(state),
|
||||||
store: writable(state),
|
subscriberCount: 0,
|
||||||
subscriberCount: 0,
|
state,
|
||||||
state,
|
parentContextStoreId,
|
||||||
parentContextStoreId,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue