Constant properties

Bacon also provides us ways to create constant properties. Constant properties are initialized at the time of creation and cannot be reinitialized, that is, new values cannot be pushed.

A constant property is created using the Bacon.constant() constructer. We need to pass the value of the property to the constructor. A constant property can be merged, concatenated, combined, zipped, sampled, filtered, and transformed.

Here is an example of how to create a constant property. Place this code in the index.js file:

var script_start_time = Bacon.constant(Date.now()).map(function(value){ var date = new Date(value); return (date).getHours() + ":" + (date).getMinutes() + ":" + (date).getSeconds(); }); script_start_time.onValue(function(value){ ...

Get JavaScript: Moving to ES2015 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.