Skip to content
Merged
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 typescript/packages/common-runner/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export interface Cell<T> {
sink(callback: (value: T) => Cancel | undefined | void): Cancel;
key<K extends T extends Cell<infer S> ? keyof S : keyof T>(
valueKey: K,
): T extends Cell<infer S> ? Cell<S[K & keyof S]> : Cell<T[K]>;
): Cell<
T extends Cell<infer S> ? S[K & keyof S] : T[K] extends never ? any : T[K]
>;
setRaw(value: T): void;
asSchema<T>(
schema?: JSONSchema,
Expand Down Expand Up @@ -167,6 +169,28 @@ export interface Stream<T> {
[isStreamMarker]: true;
}

export function getCell<T>(
space: Space,
cause: any,
schema?: JSONSchema,
log?: ReactivityLog,
): Cell<T>;
export function getCell<S extends JSONSchema = JSONSchema>(
space: Space,
cause: any,
schema: S,
log?: ReactivityLog,
): Cell<Schema<S>>;
export function getCell(
space: Space,
cause: any,
schema?: JSONSchema,
log?: ReactivityLog,
): Cell<any> {
const doc = getDoc<any>(undefined as any, cause, space);
return createCell(doc, [], log, schema);
}

export function getCellFromEntityId<T>(
space: Space,
entityId: EntityId,
Expand Down