JSFiddle - React, Tailwind, and code Playground

by leggetter

HTML

<script src="https://cdn.goinstant.net/v1/platform.min.js"></script>

JavaScript

/*
The documentation here:
https://developers.goinstant.com/v1/javascript_api/key/on.html

Seems to suggest that the parameters for `key.on` can be:

`key.on(eventName, optionsObject, listener(value, contextObject))`

However, below I'm trying:

    var options = { local: true };
    thing.on('set', options, function () {
        console.log( 'think set:', arguments );
    });
    
And I'm getting the error "on: listener must be a function".

Please open the JavaScript console to see the error.

It's as if the `options` object is expected to be the listener function.
*/

var url = 'https://goinstant.net/ccf8fe39696c/test';
var connection = goinstant.connect(url, function (err, connection, lobby) {
    if (err) {
        throw err;
    }

    var thing = lobby.key('/thing');

    var options = { local: true };
    thing.on('set', options, function () {
        console.log( 'think set:', arguments );
    });
} );