1.0.2 • Published 8 years ago

cozy-realtime-adapter v1.0.2

Weekly downloads
27
License
BSD
Repository
github
Last release
8 years ago

Realtime adapter

Helper library for interaction with cozy-data-system data changes notifications

##Server-Side : Axon -> Socket.io

Usage :

americano.start(options, function(app, server){
    app.server = server

    RealtimeAdapter = require('cozy-realtime-adapter')

    // notification events should be proxyed to client
    realtime = RealtimeAdapter(app, ['notification.*']);

    // custom callback for alarm events
    realtime.on('alarm.*', function(event, msg){
        // event = 'alarm.update' or 'alarm.create' or 'alarm.delete'
        // msg = id of the updated alarm
    });
});

##Client-Side : Socket.io -> Backbone Models manipulations

Basic Usage :

<script src="cozy-realtime-adapter.js"></script>
class SocketListener extends CozySocketListener

    models:
        'notification': Notification

    events: [
        'notification.create', 'notification.update', 'notification.delete'
    ]

    onRemoteCreate: (model) ->
        @collection.add model if # should model be in @collection ?

    onRemoteDelete: (model) ->
        @collection.remove model

sl = new SocketListener()

sl.watch myNotificationCollection

For more complex usages, refer to the code of cozy applications

What is Cozy?

Cozy Logo

Cozy is a platform that brings all your web services in the same private space. With it, your web apps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one profiles you. You install only the applications you want. You can build your own one too.

Community

You can reach the Cozy community via various support:

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.11.4

9 years ago

0.11.3

10 years ago

0.11.2

10 years ago

0.12.0

11 years ago

0.11.1

11 years ago

0.11.0

11 years ago

0.10.0

11 years ago

0.9.0

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago