New: Make SheetObject an IdentityChangeProvider
This commit is contained in:
parent
7bba9797cd
commit
08759e2d5c
1 changed files with 18 additions and 3 deletions
|
@ -13,7 +13,12 @@ import type {
|
||||||
SerializableValue,
|
SerializableValue,
|
||||||
} from '@theatre/shared/utils/types'
|
} from '@theatre/shared/utils/types'
|
||||||
import {valToAtom} from '@theatre/shared/utils/valToAtom'
|
import {valToAtom} from '@theatre/shared/utils/valToAtom'
|
||||||
import type {IDerivation, Pointer} from '@theatre/dataverse'
|
import type {
|
||||||
|
IdentityDerivationProvider,
|
||||||
|
IDerivation,
|
||||||
|
Pointer,
|
||||||
|
} from '@theatre/dataverse'
|
||||||
|
|
||||||
import {Atom, getPointerParts, pointer, prism, val} from '@theatre/dataverse'
|
import {Atom, getPointerParts, pointer, prism, val} from '@theatre/dataverse'
|
||||||
import type SheetObjectTemplate from './SheetObjectTemplate'
|
import type SheetObjectTemplate from './SheetObjectTemplate'
|
||||||
import TheatreSheetObject from './TheatreSheetObject'
|
import TheatreSheetObject from './TheatreSheetObject'
|
||||||
|
@ -25,11 +30,11 @@ import TheatreSheetObject from './TheatreSheetObject'
|
||||||
// sequenced: SerializableMap
|
// sequenced: SerializableMap
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export default class SheetObject {
|
export default class SheetObject implements IdentityDerivationProvider {
|
||||||
get type(): 'Theatre_SheetObject' {
|
get type(): 'Theatre_SheetObject' {
|
||||||
return 'Theatre_SheetObject'
|
return 'Theatre_SheetObject'
|
||||||
}
|
}
|
||||||
|
readonly $$isIdentityDerivationProvider: true = true
|
||||||
readonly address: SheetObjectAddress
|
readonly address: SheetObjectAddress
|
||||||
readonly publicApi: TheatreSheetObject<$IntentionalAny>
|
readonly publicApi: TheatreSheetObject<$IntentionalAny>
|
||||||
private readonly _initialValue = new Atom<SerializableMap>({})
|
private readonly _initialValue = new Atom<SerializableMap>({})
|
||||||
|
@ -130,6 +135,16 @@ export default class SheetObject {
|
||||||
return val(pointerDeep(allValuesP as $FixMe, path)) as SerializableMap
|
return val(pointerDeep(allValuesP as $FixMe, path)) as SerializableMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getIdentityDerivation(path: Array<string | number>): IDerivation<unknown> {
|
||||||
|
/**
|
||||||
|
* @todo perf: Too much indirection here.
|
||||||
|
*/
|
||||||
|
return prism(() => {
|
||||||
|
const allValuesP = val(this.getValues())
|
||||||
|
return val(pointerDeep(allValuesP as $FixMe, path)) as SerializableMap
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns values of props that are sequenced.
|
* Returns values of props that are sequenced.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue