readReplicant

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

NameTypeAttributesDefaultDescription
namestringThe name of the replicant.
bundlestring<optional>CURR_BNDLThe bundle namespace to in which to look for this replicant.
cbfunctionBrowser 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 + '!');
});
Last updated on by Clubwho