telepat-js

0.4.8 • Public • Published

NPM Bower David

Telepat Javascript Client

UMD client for Telepat, using Webpack to run in browsers. Available on GitHub.

Telepat is an open-source backend stack, designed to deliver information and information updates in real-time to clients, while allowing for flexible deployment and simple scaling. Read more about how it works and why it's different here.

Installing

  • bower install telepat-js, if you're using Bower
  • npm install telepat-js, if you're using NPM
  • or the classic <script src="lib/telepat.js"></script>

Learning

Documentation is available here, and you can check out a simple demo here.

A simple usage example:

let telepat = new Telepat();
telepat.connect({
 apiEndpoint: 'TELEPAT-API-ENDPOINT',
 socketEndpoint: 'TELEPAT-SOCKET-ENDPOINT',
 apiKey: 'APP-API-KEY',
 appId: 'APP-ID'
}, (err, res) => {
 if (err) {
   // Treat connection error
   console.log(err);
   return;
 }
 
 // Display all collections
 console.log(telepat.collections);
 
 // Login, display and update user data
 telepat.on('login', () => {
   console.log(telepat.user.data);
   telepat.user.data.change = true;
 });
 telepat.user.login('user', 'pass');
 
 // Subscribe to data
 let articleChannel = telepat.subscribe({
   channel: {
     context: 'collection-identifier',
     model: 'article'
   }
 }, () => {
   console.log(articleChannel.objectsArray);
   articleChannel.objects['object-identifier'].title = 'new title';
 
   articleChannel.on('update', (operationType, objectId, object, oldObject) => {
     // Update interface on data updates
   });
 });
});

Building from source

Clone the repo, then run npm install. After editing the sources in the /src directory, run npm run build-all to compile the libraries, and npm run docs to generate the documentation.

License

Released under the Apache 2 License.

Credits

Telepat is built on top of the following awesome libraries:

Package Sidebar

Install

npm i telepat-js

Homepage

telepat.io

Weekly Downloads

2

Version

0.4.8

License

MIT

Last publish

Collaborators

  • telepat