Skip to content

Cookbook: track

Eugene Lazutkin edited this page Nov 26, 2019 · 3 revisions

In order to use io.track make sure that it is enabled:

// activate the package
io.track.attach();

See How to include for more details. See track for the full documentation.

Register an interest

We can register an interest in an I/O request without initiating it:

// register for a value
io.get({
  url: '/url',
  wait: true
}).then(function (value) {
  console.log('Delayed value:', value);
});

// ...

// now we request it
io.get('/url').then(function (value) {
  console.log('Got value:', value);
});

// eventually it will print two lines:
// Delayed value: 42
// Got value: 42
Clone this wiki locally