21
readReplicant.md
Normal file
21
readReplicant.md
Normal file
@ -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 <optional> 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 + '!');
|
||||
});
|
||||
Reference in New Issue
Block a user