You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 28, 2020. It is now read-only.
It would be nice to be able to provide arguments to the polling function. For instance, we could write a polling to retrieve the private messages of a user on a website:
// Define a polling that fetch a user's messages by GETting a resourcevarpolling=AsyncPolling(function(userId,end){varuserMessagesUrl='http://example.com/messages/user/'+encodeURIComponent(userId);fetch(userMessagesUrl).then(function(response){varmessages=// extract messages from responseend(null,messages);}).catch(end);},2000);// Attach a listener to display the messages when they are received:polling.on('result',function(messages){// Do something with the messages});// Run the polling for a user with ID `1`:polling.run(1);// Let's say they disconnect and another user log in:polling.stop()polling.run(newUserId);
I find this cleaner than relying on a global state or something like that.
It would be nice to be able to provide arguments to the polling function. For instance, we could write a polling to retrieve the private messages of a user on a website:
I find this cleaner than relying on a global state or something like that.