UNPKG

rafa

Version:

Rafa.js is a Javascript framework for building concurrent applications.

22 lines (17 loc) 544 B
Read a value from the channel by providing a callback function that accepts a value. The method returns 1 is the callback was called immediately, 2 if the callback was registered to receive the next value written, and 0 if the callback was already registered. <aside> ```js // read(callback: A => _): Int var channel = Rafa.channel(); var values = []; var results = []; results.push(channel.read(v => values.push(v+1))); results.push(channel.read(v => values.push(v+2))); channel.write(1); // values: [2]; // results: [2,0]; ``` </aside>