updated examples

This commit is contained in:
Kevin Jahns 2014-08-19 21:19:05 +02:00
parent 92e23b7007
commit 671174e17f
2 changed files with 16 additions and 4 deletions

View File

@ -11,6 +11,11 @@ First you have to include the following libraries in your html file:
<script src="./index.js"></script> <script src="./index.js"></script>
``` ```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js) A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
### Create Connector
The PeerJs Framework requires an API key, or you need to set up your own PeerJs server.
Get an API key from the Website.
The first parameter of `createPeerJsConnector` is the options object in PeerJs.
```js ```js
@ -19,13 +24,13 @@ Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
``` ```
### Yatta
yatta is the shared json object. If you change something on this object, yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators. it will be instantly shared with all the other collaborators.
```js ```js
yattaHandler = new Y.JsonYatta(user_id, Connector); yatta = new Y.JsonYatta(user_id, Connector);
yatta = yattaHandler.getSharedObject();
``` ```
@ -156,6 +161,7 @@ Apply 'insert' and 'delete' - listeners to Words.
``` ```
### Experimental method
But there is a much more convenient way! But there is a much more convenient way!

View File

@ -13,15 +13,20 @@
<script src="./index.js"></script> <script src="./index.js"></script>
``` ```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js) A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
### Create Connector
The PeerJs Framework requires an API key, or you need to set up your own PeerJs server.
Get an API key from the Website.
The first parameter of `createPeerJsConnector` is the options object in PeerJs.
*/ */
var yatta, yattaHandler; var yatta, yattaHandler;
Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){ Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
/** /**
### Yatta
yatta is the shared json object. If you change something on this object, yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators. it will be instantly shared with all the other collaborators.
*/ */
yattaHandler = new Y.JsonYatta(user_id, Connector); yatta = new Y.JsonYatta(user_id, Connector);
yatta = yattaHandler.getSharedObject();
/** /**
Add a integer-property like this Add a integer-property like this
@ -119,6 +124,7 @@ Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
/** /**
### Experimental method
But there is a much more convenient way! But there is a much more convenient way!
*/ */
console.log(yatta.value.list[2] === 3) // true console.log(yatta.value.list[2] === 3) // true