This quickstart guide is for the JavaScript SDK. If you use Android, please refer to this article.
Create your own account and application on the [[console]]
If you use Node.JS, please refer to this article
Add the javascript library to your HTML page:
<script type='text/javascript' src='[[siteUrl]]/libjs/latest/webcom.js'></script>
Or install package via npm and reference [[service]] library in your web application
npm install webcom
<script type='text/javascript' src='YOUR_LIBRARY_PATH/webcom.js'></script>
or else with import:
import 'webcom/webcom.js';
or else you could add in your 'webpack.config.js' :
module.exports = {
[...]
resolve: {
alias: {
webcom: 'webcom/webcom.js'
}
}
};
and then just import 'webcom'
will work well.
In javascript, create a Webcom reference to your [[service]] application:
var myRef = new Webcom('<your-app>');
Listen to changes:
myRef.on('child_added', function(snapShot){ // If another users call ref.set({foo: 'bar'}) then snapShot.val() will be equal to 'bar' // If another users call ref.push({foo: 'bar'}) then snapShot.val() will be equal to {foo: 'bar'} console.info(snapShot.val()); });
Write data to myRef:
myRef.set({foo: 'bar'});
or Create a new child data to myRef:
var barRef = myRef.set({bar: 'baz'});