Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/llafuente/object-synchronization
Object synchronization across network using tcp or socket.io And If you implement three functions, you could have your own transport easily.
https://github.com/llafuente/object-synchronization
Last synced: 1 day ago
JSON representation
Object synchronization across network using tcp or socket.io And If you implement three functions, you could have your own transport easily.
- Host: GitHub
- URL: https://github.com/llafuente/object-synchronization
- Owner: llafuente
- Created: 2012-11-20T16:18:20.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-09-19T11:18:19.000Z (over 11 years ago)
- Last Synced: 2024-11-07T06:43:09.575Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# object-synchronization [![Build Status](https://secure.travis-ci.org/llafuente/object-synchronization.png?branch=master)](http://travis-ci.org/llafuente/object-synchronization)
==========## Introduction
============Object synchronization across network using tcp or socket.io
And If you implement three functions, you could have your own transport easily.The "sockets" setup is in your side see the examples.
## Observer
============while Object.observe arrive... we have to use this to setup an object that listen to itself an emit the proper changes
Note: this is not a shim of Object.observe.* new Observer(Object object);
* .observer(Function callback);
* .observe(String property);
* .__observe(String property); // internal, do not trigger the callback
* .__set(String property, Mixed value); // internal, do not trigger the callbackExample:
``` js
var obj = new Observer({
test: true
}, function() {
console.log(arguments);
}); // -> { '0': 'observe', '1': 'test' }console.log(obj.test); // true
obj.test = false; // { '0': 'change', '1': 'test', '2': false }
console.log(obj.test); // false```
## Sync
============* new SyncSocketIO() / SyncTCP
* .add_socket(Socket socket, Boolean sync_now)
* .get_object(String id)
* .observe(String id, Object object, Boolean prevent_emit)SocketIO example [/test/test-socket_io.js](https://github.com/llafuente/object-synchronization/blob/master/test/test-socket_io.js)
TCP example [/test/test-tcp.js](https://github.com/llafuente/object-synchronization/blob/master/test/test-tcp.js)## Install
==========With [npm](http://npmjs.org) do:
```
npm install object-synchronization
```
## license
==========MIT.