Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __experimental_sequenceProp to studio.transaction() #449

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion theatre/studio/src/TheatreStudio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {IProject, IRafDriver, ISheet, ISheetObject} from '@theatre/core'
import type {Prism, Pointer} from '@theatre/dataverse'
import {prism} from '@theatre/dataverse'
import {getPointerParts, prism} from '@theatre/dataverse'
import SimpleCache from '@theatre/utils/SimpleCache'
import type {$IntentionalAny, VoidFn} from '@theatre/utils/types'
import type {IScrub} from '@theatre/studio/Scrub'
Expand Down Expand Up @@ -88,6 +88,13 @@ export interface ITransactionAPI {
* Makes Theatre forget about this sheet.
*/
__experimental_forgetSheet(sheet: TheatreSheet): void

/**
* EXPERIMENTAL API - this api may be removed without notice.
*
* Sequences a track for the
*/
__experimental_sequenceProp<V>(pointer: Pointer<V>): void
}
/**
*
Expand Down Expand Up @@ -571,11 +578,28 @@ export default class TheatreStudio implements IStudio {
)
}

const __experimental_sequenceProp = <V>(prop: Pointer<V>) => {
const {path, root} = getPointerParts(prop)

if (!isSheetObject(root)) {
throw new Error(
'Argument prop must be a pointer to a SheetObject property',
)
}

const propAdress = {...root.address, pathToProp: path}

stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAdress,
)
}

return fn({
set,
unset,
__experimental_forgetObject,
__experimental_forgetSheet,
__experimental_sequenceProp,
})
})
}
Expand Down
Loading