Skip to content

nforce is a node.js salesforce REST API wrapper for force.com, database.com, and salesforce.com

License

Notifications You must be signed in to change notification settings

dhulke/sforcejs

 
 

Repository files navigation

Sforcejs :: node.js salesforce REST API wrapper with backpressure

Sforcejs is a copy of the nforce module with support for streaming backpressure by using the Bayeuxjs package, instead of Faye. The following is an example of the additional feature this package provides.

Streaming Client

Lastevent trigger

The lastevent event is triggered after the last data event of the current page has been triggered. The lastevent event will receive a callback as a parameter that will request additional events when called. This mechanism provides a way to control the flow of events from the data source.

org.authenticate({ username: user, password: pass }, function(err, oauth) {

  if(err) return console.log(err);

  console.log('subscribing to NewAccounts');
  var accs = org.subscribeAsync({ topic: 'NewAccounts' });

  accs.on('error', function(err) {
    console.log('subscription error');
    console.log(err);
    client.disconnect();
  });

  accs.on('data', function(data) {
    console.log(data);
  });
    
  accs.on('lastevent', lazyConnect => {
    console.log("lastEventReceived. Requesting more events");
    setTimeout(lazyConnect, 5000);
  });


});

subscribe(opts)

  • channel: (String:optional) A string value for the streaming channel (ex. /data/CaseChangeEvent).
  • isCDC: (Boolean:optional) Specify true if the topic to be streamed is a Change Data Capture (CDC).

About

nforce is a node.js salesforce REST API wrapper for force.com, database.com, and salesforce.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%