isSynchronizable
Available from 0.6.0
Asserts whether a value is a Synchronizable.
You can pass a generic type argument, such as isSynchronizable<number>(value), to narrow the value to Synchronizable<number> in TypeScript. This checks whether the value is a Synchronizable; it does not check the type of the data inside it.
Reference
Check both a Synchronizable and a plain object, then guard an update with isSynchronizable. The shared value changes from 0 to 42.
Code
Code
Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.
const counter = createSynchronizable(0);
console.log(isSynchronizable(counter)); // true
console.log(isSynchronizable({ count: 0 })); // false
if (isSynchronizable(counter)) {
counter.setBlocking(42);
}
console.log(counter.getBlocking()); // 42
Console 0
No output yet
Output appears here as the code runs.


Type definitions
function isSynchronizable<TValue = unknown>(
value: unknown
): value is Synchronizable<TValue>;
Arguments
value
The value to be checked.
Remarks
isSynchronizablecan be called from any JavaScript Runtime.