syndicate-js/examples/how-to-use-syndicate-tsc/src/box.ts

19 lines
584 B
TypeScript
Raw Normal View History

2021-12-01 16:24:29 +00:00
/// SPDX-License-Identifier: GPL-3.0-or-later
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
import { BoxState, SetBox, N } from './protocol.js';
2021-12-02 23:55:42 +00:00
import { Ref } from '@syndicate-lang/core';
export function boot(ds: Ref) {
spawn named 'box' {
2021-12-02 23:55:42 +00:00
field boxValue: number = 0;
at ds {
assert BoxState(boxValue.value);
on message SetBox($v: number) => boxValue.value = v;
}
stop on (boxValue.value === N) {
console.log('terminated box root facet');
2021-12-02 23:55:42 +00:00
}
}
}