Browse Source

Update documentation;

bjorn 9 years ago
parent
commit
e5bfa7cf32
3 changed files with 73 additions and 19 deletions
  1. 71 17
      doc/README.md
  2. 1 1
      rx.lua
  3. 1 1
      src/observable.lua

+ 71 - 17
doc/README.md

@@ -1,6 +1,9 @@
 RxLua
 RxLua
 ===
 ===
 
 
+- [Subscription](#subscription)
+  - [create](#createaction)
+  - [unsubscribe](#unsubscribe)
 - [Observer](#observer)
 - [Observer](#observer)
   - [create](#createonnext-onerror-oncomplete)
   - [create](#createonnext-onerror-oncomplete)
   - [onNext](#onnextvalues)
   - [onNext](#onnextvalues)
@@ -45,7 +48,6 @@ RxLua
   - [window](#windowsize)
   - [window](#windowsize)
   - [with](#withsources)
   - [with](#withsources)
   - [wrap](#wrapsize)
   - [wrap](#wrapsize)
-- [Scheduler](#scheduler)
 - [ImmediateScheduler](#immediatescheduler)
 - [ImmediateScheduler](#immediatescheduler)
   - [create](#create)
   - [create](#create)
   - [schedule](#scheduleaction)
   - [schedule](#scheduleaction)
@@ -55,13 +57,37 @@ RxLua
   - [update](#updatedelta)
   - [update](#updatedelta)
   - [isEmpty](#isempty)
   - [isEmpty](#isempty)
 - [Subject](#subject)
 - [Subject](#subject)
-  - [create](#createvalue)
+  - [create](#create)
   - [subscribe](#subscribeonnext-onerror-oncomplete)
   - [subscribe](#subscribeonnext-onerror-oncomplete)
   - [onNext](#onnextvalues)
   - [onNext](#onnextvalues)
   - [onError](#onerrormessage)
   - [onError](#onerrormessage)
   - [onComplete](#oncomplete)
   - [onComplete](#oncomplete)
+- [BehaviorSubject](#behaviorsubject)
+  - [create](#createvalue)
+  - [subscribe](#subscribeonnext-onerror-oncomplete)
+  - [onNext](#onnextvalues)
   - [getValue](#getvalue)
   - [getValue](#getvalue)
 
 
+# Subscription
+
+A handle representing the link between an Observer and an Observable, as well as any work required to clean up after the Observable completes or the Observer unsubscribes.
+
+---
+
+#### `.create(action)`
+
+Creates a new Subscription.
+
+| Name | Type | Default | Description |
+|------|------|---------|-------------|
+| `action` | function (optional) |  | The action to run when the subscription is unsubscribed. It will only be run once. |
+
+---
+
+#### `:unsubscribe()`
+
+Unsubscribes the subscription, performing any necessary cleanup work.
+
 # Observer
 # Observer
 
 
 Observers are simple objects that receive values from Observables.
 Observers are simple objects that receive values from Observables.
@@ -459,10 +485,6 @@ Returns an Observable that buffers values from the original and produces them as
 |------|------|---------|-------------|
 |------|------|---------|-------------|
 | `size` | number |  | The size of the buffer. |
 | `size` | number |  | The size of the buffer. |
 
 
-# Scheduler
-
-Schedulers manage groups of Observables.
-
 # ImmediateScheduler
 # ImmediateScheduler
 
 
 Schedules Observables by running all operations immediately.
 Schedules Observables by running all operations immediately.
@@ -471,7 +493,7 @@ Schedules Observables by running all operations immediately.
 
 
 #### `.create()`
 #### `.create()`
 
 
-Creates a new Immediate Scheduler.
+Creates a new ImmediateScheduler.
 
 
 ---
 ---
 
 
@@ -491,7 +513,7 @@ Manages Observables using coroutines and a virtual clock that must be updated ma
 
 
 #### `.create(currentTime)`
 #### `.create(currentTime)`
 
 
-Creates a new Cooperative Scheduler.
+Creates a new CooperativeScheduler.
 
 
 | Name | Type | Default | Description |
 | Name | Type | Default | Description |
 |------|------|---------|-------------|
 |------|------|---------|-------------|
@@ -512,7 +534,7 @@ Schedules a function to be run after an optional delay.
 
 
 #### `:update(delta)`
 #### `:update(delta)`
 
 
-Triggers an update of the Cooperative Scheduler. The clock will be advanced and the scheduler will run any coroutines that are due to be run.
+Triggers an update of the CooperativeScheduler. The clock will be advanced and the scheduler will run any coroutines that are due to be run.
 
 
 | Name | Type | Default | Description |
 | Name | Type | Default | Description |
 |------|------|---------|-------------|
 |------|------|---------|-------------|
@@ -522,7 +544,7 @@ Triggers an update of the Cooperative Scheduler. The clock will be advanced and
 
 
 #### `:isEmpty()`
 #### `:isEmpty()`
 
 
-Returns whether or not the Cooperative Scheduler's queue is empty.
+Returns whether or not the CooperativeScheduler's queue is empty.
 
 
 # Subject
 # Subject
 
 
@@ -530,14 +552,10 @@ Subjects function both as an Observer and as an Observable. Subjects inherit all
 
 
 ---
 ---
 
 
-#### `.create(value)`
+#### `.create()`
 
 
 Creates a new Subject.
 Creates a new Subject.
 
 
-| Name | Type | Default | Description |
-|------|------|---------|-------------|
-| `value` | *... |  | The initial values. |
-
 ---
 ---
 
 
 #### `:subscribe(onNext, onError, onComplete)`
 #### `:subscribe(onNext, onError, onComplete)`
@@ -546,7 +564,7 @@ Creates a new Observer and attaches it to the Subject.
 
 
 | Name | Type | Default | Description |
 | Name | Type | Default | Description |
 |------|------|---------|-------------|
 |------|------|---------|-------------|
-| `onNext` | function |  | Called when the Subject produces a value. |
+| `onNext` | function|table |  | A function called when the Subject produces a value or an existing Observer to attach to the Subject. |
 | `onError` | function |  | Called when the Subject terminates due to an error. |
 | `onError` | function |  | Called when the Subject terminates due to an error. |
 | `onComplete` | function |  | Called when the Subject completes normally. |
 | `onComplete` | function |  | Called when the Subject completes normally. |
 
 
@@ -554,7 +572,7 @@ Creates a new Observer and attaches it to the Subject.
 
 
 #### `:onNext(values)`
 #### `:onNext(values)`
 
 
-Pushes zero or more values to the Subject. It will be broadcasted to all Observers.
+Pushes zero or more values to the Subject. They will be broadcasted to all Observers.
 
 
 | Name | Type | Default | Description |
 | Name | Type | Default | Description |
 |------|------|---------|-------------|
 |------|------|---------|-------------|
@@ -576,6 +594,42 @@ Signal to all Observers that an error has occurred.
 
 
 Signal to all Observers that the Subject will not produce any more values.
 Signal to all Observers that the Subject will not produce any more values.
 
 
+# BehaviorSubject
+
+A Subject that tracks its current value. Provides an accessor to retrieve the most recent pushed value, and all subscribers immediately receive the latest value.
+
+---
+
+#### `.create(value)`
+
+Creates a new BehaviorSubject.
+
+| Name | Type | Default | Description |
+|------|------|---------|-------------|
+| `value` | *... |  | The initial values. |
+
+---
+
+#### `:subscribe(onNext, onError, onComplete)`
+
+Creates a new Observer and attaches it to the Subject. Immediately broadcasts the most recent value to the Observer.
+
+| Name | Type | Default | Description |
+|------|------|---------|-------------|
+| `onNext` | function |  | Called when the Subject produces a value. |
+| `onError` | function |  | Called when the Subject terminates due to an error. |
+| `onComplete` | function |  | Called when the Subject completes normally. |
+
+---
+
+#### `:onNext(values)`
+
+Pushes zero or more values to the BehaviorSubject. They will be broadcasted to all Observers.
+
+| Name | Type | Default | Description |
+|------|------|---------|-------------|
+| `values` | *... |  |  |
+
 ---
 ---
 
 
 #### `:getValue()`
 #### `:getValue()`

+ 1 - 1
rx.lua

@@ -844,7 +844,7 @@ function Observable:tap(_onNext, _onError, _onComplete)
   end)
   end)
 end
 end
 
 
---- Returns an Observable that util.unpacks the tables produced by the original.
+--- Returns an Observable that unpacks the tables produced by the original.
 -- @returns {Observable}
 -- @returns {Observable}
 function Observable:unpack()
 function Observable:unpack()
   return self:map(util.unpack)
   return self:map(util.unpack)

+ 1 - 1
src/observable.lua

@@ -759,7 +759,7 @@ function Observable:tap(_onNext, _onError, _onComplete)
   end)
   end)
 end
 end
 
 
---- Returns an Observable that util.unpacks the tables produced by the original.
+--- Returns an Observable that unpacks the tables produced by the original.
 -- @returns {Observable}
 -- @returns {Observable}
 function Observable:unpack()
 function Observable:unpack()
   return self:map(util.unpack)
   return self:map(util.unpack)