📜 ⬆️ ⬇️

Feathers.js - a reactive JavaScript framework on top of Express

image
Feathers.js is a reactive JavaScript framework inspired by Sails , Flatiron and Derby . The app on feathers.js resembles the usual expressjs application, only instead
var app = require('express')(); 
will need to write
 var app = require('feathers')(); 

For collections, a full-fledged RESTful API is created, synchronization is conducted via SocketIO events.

RESTful
 // POST http://localhost:8000/todos { "description": "You have to do dishes!" } // GET http://localhost:8000/todos [ { "id": 0, "description": "You have to do dishes!" } ] 


Sample SocketIO client code
 <script src="http://localhost:8000/socket.io/socket.io.js" /> <script type="text/javascript"> var socket = io.connect('http://localhost:8000/'); socket.on('todos created', function(todo) { console.log('Someone created a new Todo', todo); }); socket.emit('todos::create', { description: 'You have to do something real-time!' }, {}, function(error, todo) { socket.emit('todos::find', {}, function(error, todos) { console.log('Server todos:', todos); }); }); </script> 


Data access is described as a service:

 var myService = { find: function(params, callback) {}, get: function(id, params, callback) {}, create: function(data, params, callback) {}, update: function(id, data, params, callback) {}, remove: function(id, params, callback) {}, setup: function(app) {} } 

I advise you to look at the standard TODO example . The demo link (reactive - when one of the users changes the data, everyone sees the change immediately) and the code: both client and server.

Documentation is quite visual and imputed.
')
In my opinion, the framework is quite easy and pleasant. 20 minutes to learn and you can do reactive things on the site.

Source: https://habr.com/ru/post/206092/


All Articles