From e52078da6a9be6fd637367b6e494449cc588fa13 Mon Sep 17 00:00:00 2001 From: sZLukas1607 Date: Fri, 29 May 2020 08:46:29 +0200 Subject: [PATCH] --- readReplicant.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 readReplicant.md diff --git a/readReplicant.md b/readReplicant.md new file mode 100644 index 0000000..8cb46ef --- /dev/null +++ b/readReplicant.md @@ -0,0 +1,21 @@ +readReplicant(name, *bundle, cb) +Reads the value of a replicant once, and doesn't create a subscription to it. Also available as a static method. +#Parameters +Name Type Attributes Default Description +name string The name of the replicant. +bundle string CURR_BNDL The bundle namespace to in which to look for this replicant. +cb function Browser only The callback that handles the server's response which contains the value. +#Example +From an extension: +// Extensions have immediate access to the database of Replicants. +// For this reason, they can use readReplicant synchronously, without a callback. +module.exports = function(nodecg) { + var myVal = nodecg.readReplicant('myVar', 'some-bundle'); +}; +From a graphic or dashboard panel: +// Graphics and dashboard panels must query the server to retrieve the value, +// and therefore must provide a callback. +nodecg.readReplicant('myRep', 'some-bundle', value => { + // I can use 'value' now! + console.log('myRep has the value ' + value + '!'); +});