Skip to content
Snippets Groups Projects
Commit a9d20c7e authored by David Sehnal's avatar David Sehnal
Browse files

mol-state: generic StateObjectCell

parent fc90ee91
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ namespace StateObject {
};
}
interface StateObjectCell {
interface StateObjectCell<T = StateObject> {
transform: Transform,
// Which object was used as a parent to create data in this cell
......@@ -68,7 +68,7 @@ interface StateObjectCell {
} | undefined;
errorText?: string,
obj?: StateObject
obj?: T
}
namespace StateObjectCell {
......
......@@ -29,7 +29,7 @@ namespace StateSelection {
}
function isObj(arg: any): arg is StateObjectCell {
return (arg as StateObjectCell).version !== void 0;
return (arg as StateObjectCell).version !== void 0 && (arg as StateObjectCell).transform !== void 0;
}
function isBuilder(arg: any): arg is Builder {
......
......@@ -5,7 +5,7 @@
*/
import { Task } from 'mol-task';
import { StateObject } from './object';
import { StateObject, StateObjectCell } from './object';
import { Transform } from './transform';
import { ParamDefinition as PD } from 'mol-util/param-definition';
import { StateAction } from './action';
......@@ -24,6 +24,7 @@ export namespace Transformer {
export type Params<T extends Transformer<any, any, any>> = T extends Transformer<any, any, infer P> ? P : unknown;
export type From<T extends Transformer<any, any, any>> = T extends Transformer<infer A, any, any> ? A : unknown;
export type To<T extends Transformer<any, any, any>> = T extends Transformer<any, infer B, any> ? B : unknown;
export type Cell<T extends Transformer<any, any, any>> = T extends Transformer<any, infer B, any> ? StateObjectCell<B> : unknown;
export function is(obj: any): obj is Transformer {
return !!obj && typeof (obj as Transformer).toAction === 'function' && typeof (obj as Transformer).apply === 'function';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment