@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
35 lines • 1.02 kB
JavaScript
import { Node } from '../../programmatic/node.js';
import { NumberSchema } from '../../schemas/index.js';
/**
* A node that returns the current time each tick in seconds since the Unix epoch.
* When the node is started, it will update the time every second.
*/
export default class NodeDefinition extends Node {
static title = 'Time';
static type = 'studio.tokens.generic.time';
static description = 'Provides the current time each tick';
_interval = null;
constructor(props) {
super(props);
this.addOutput('value', {
type: NumberSchema
});
}
onStart = () => {
if (this._interval) {
clearInterval(this._interval);
}
this._interval = setInterval(() => {
this.run();
}, 1000);
};
onStop = () => {
if (this._interval) {
clearInterval(this._interval);
}
};
execute() {
this.outputs.value.set(Date.now());
}
}
//# sourceMappingURL=time.js.map