Skip to content

Commit

Permalink
docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
studentIvan committed Jan 15, 2015
1 parent 68e3c84 commit 21e6b0f
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 4 deletions.
93 changes: 89 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
API
===
API:duel
========

duel
----
Expand All @@ -8,6 +8,14 @@ Main global object.
* global
* type: object

duel.activeChannels
-------------------
Collect inside all active channels.

* public
* type: array
* default: []

duel.useStorageEvent
--------------------
Optional configuration. Storage event improves performance in modern browsers.
Expand All @@ -24,6 +32,22 @@ Common function for localStorage detection.
* type: function
* returns: boolean

duel.channel(name:string)
-------------------------
Creates a new channel or join to existed.
Hint: a = duel.channel('x') and b = duel.channel('x') will be linking on ONE object.

* public
* type: function
* returns: object (duel.DuelAbstractChannel inheritor)

duel.makeCurrentWindowMaster()
------------------------------
Take the all channels in current window and set current window as master for all of them.

* public
* type: function

duel.clone(obj:object)
----------------------
Common function for copy objects.
Expand All @@ -33,9 +57,70 @@ Common function for copy objects.
* returns: object
* throws error on unsupported type

duel._generateWindowID()
------------------------
Generates, sets up and returns new window/tab ID.

* private
* type: function
* returns: number

duel.getWindowID()
------------------
Get unique window/tab ID.

* public
* type: function
* returns: number

duel.addEvent(el:object, type:string, fn:function)
--------------------------------------------------
Cross-browser addEvent method.

* public
* type: function

duel.storageEvent(event:object)
-------------------------------
Finds the specific channel and execute event on it. **event** object contains **key:string** and **newValue:string**.
**newValue** is a JSON string, which contains **channelName:string** and **triggerDetails:object**.
**triggerDetails** contains **name:string** and **args:array**.

* public
* type: function

duel.DuelAbstractChannel
------------------------
Abstract class for possible duel channels. Will support another channels besides localStorage in future.
Abstract class for possible duel channels. DuelJS probably will support another channels besides **duel.DuelLocalStorageChannel** in future.

* abstract
* type: object
* type: function
* returns: object

duel.DuelLocalStorageChannel
----------------------------
Channel class for work with localStorage.

* abstract
* type: function
* returns: object

duel.DuelFakeChannel
--------------------
Channel class for work without localStorage.

* abstract
* type: function
* returns: object

window.isMaster()
-----------------
Take first channel in current window and check is it master or not

Standard window object spreading method.
Looks like syntax sugar for channelObject.currentWindowIsMaster()

* public
* type: function
* returns: boolean

74 changes: 74 additions & 0 deletions docs/channel_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
API:channel object interface
============================

channel.getName()
-----------------
Returns the name of this channel.

* public
* type: function
* returns: string

channel.setCurrentWindowAsMaster()
----------------------------------
Makes current window/tab as master in this channel.

* public
* type: function
* returns: boolean

channel.currentWindowIsMaster()
-------------------------------
Checks the master state of this channel.

* public
* type: function
* returns: boolean

channel.broadcast(trigger:string[, arguments:arguments])
--------------------------------------------------------
Emits broadcasting. Hint: only master can sends broadcast.

* public
* type: function

channel.emit(trigger:string[, arguments:arguments])
---------------------------------------------------
Alias of **channel.broadcast**

channel.executeTrigger(triggerDetails:object[, force:boolean])
--------------------------------------------------------------
Executes pointed trigger. **triggerDetails** contains **name:string** and **args:array**

* public
* type: function
* throws error if triggerDetails is not an instance of Object

channel.on(trigger:string, callback:function)
---------------------------------------------
Attaches callback to trigger event.

* public
* type: function

channel.once(trigger:string, callback:function)
-----------------------------------------------
Attaches callback to trigger event only for one time.

* public
* type: function

channel.off(trigger:string)
---------------------------
Detaches callback from trigger event (destroys trigger).

* public
* type: function

channel._triggers
-----------------
Contains triggers of this channel.

* private
* type: object

1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ User Documentation

getting_started
api
channel_api

0 comments on commit 21e6b0f

Please sign in to comment.