浏览代码

Rename fromValue to of;

bjorn 8 年之前
父节点
当前提交
4b0833d44e

+ 1 - 1
README.md

@@ -44,7 +44,7 @@ local Rx = require 'rx'
 
 
 Rx.Observable.fromRange(1, 8)
 Rx.Observable.fromRange(1, 8)
   :filter(function(x) return x % 2 == 0 end)
   :filter(function(x) return x % 2 == 0 end)
-  :concat(Rx.Observable.fromValue('who do we appreciate'))
+  :concat(Rx.Observable.of('who do we appreciate'))
   :map(function(value) return value .. '!' end)
   :map(function(value) return value .. '!' end)
   :subscribe(print)
   :subscribe(print)
 
 

+ 4 - 4
doc/README.md

@@ -15,7 +15,7 @@ RxLua
   - [empty](#empty)
   - [empty](#empty)
   - [never](#never)
   - [never](#never)
   - [throw](#throwmessage)
   - [throw](#throwmessage)
-  - [fromValue](#fromvaluevalue)
+  - [of](#ofvalues)
   - [fromRange](#fromrangeinitial-limit-step)
   - [fromRange](#fromrangeinitial-limit-step)
   - [fromTable](#fromtabletable-iterator-keys)
   - [fromTable](#fromtabletable-iterator-keys)
   - [fromCoroutine](#fromcoroutinecoroutine)
   - [fromCoroutine](#fromcoroutinecoroutine)
@@ -215,13 +215,13 @@ Returns an Observable that immediately produces an error.
 
 
 ---
 ---
 
 
-#### `.fromValue(value)`
+#### `.of(values)`
 
 
-Creates an Observable that produces a single value.
+Creates an Observable that produces a set of values.
 
 
 | Name | Type | Default | Description |
 | Name | Type | Default | Description |
 |------|------|---------|-------------|
 |------|------|---------|-------------|
-| `value` | * |  |  |
+| `values` | *... |  |  |
 
 
 ---
 ---
 
 

+ 1 - 1
examples/simple.lua

@@ -1,4 +1,4 @@
 local Rx = require 'rx'
 local Rx = require 'rx'
 
 
 -- Create an observable that produces a single value and print it.
 -- Create an observable that produces a single value and print it.
-Rx.Observable.fromValue(42):subscribe(print)
+Rx.Observable.of(42):subscribe(print)

+ 9 - 4
rx.lua

@@ -143,12 +143,17 @@ function Observable.throw(message)
   end)
   end)
 end
 end
 
 
---- Creates an Observable that produces a single value.
--- @arg {*} value
+--- Creates an Observable that produces a set of values.
+-- @arg {*...} values
 -- @returns {Observable}
 -- @returns {Observable}
-function Observable.fromValue(value)
+function Observable.of(...)
+  local args = {...}
+  local argCount = select('#', ...)
   return Observable.create(function(observer)
   return Observable.create(function(observer)
-    observer:onNext(value)
+    for i = 1, argCount do
+      observer:onNext(args[i])
+    end
+
     observer:onCompleted()
     observer:onCompleted()
   end)
   end)
 end
 end

+ 9 - 4
src/observable.lua

@@ -48,12 +48,17 @@ function Observable.throw(message)
   end)
   end)
 end
 end
 
 
---- Creates an Observable that produces a single value.
--- @arg {*} value
+--- Creates an Observable that produces a set of values.
+-- @arg {*...} values
 -- @returns {Observable}
 -- @returns {Observable}
-function Observable.fromValue(value)
+function Observable.of(...)
+  local args = {...}
+  local argCount = select('#', ...)
   return Observable.create(function(observer)
   return Observable.create(function(observer)
-    observer:onNext(value)
+    for i = 1, argCount do
+      observer:onNext(args[i])
+    end
+
     observer:onCompleted()
     observer:onCompleted()
   end)
   end)
 end
 end

+ 2 - 2
tests/all.lua

@@ -21,10 +21,10 @@ describe('all', function()
   end)
   end)
 
 
   it('uses the identity function as a predicate if none is specified', function()
   it('uses the identity function as a predicate if none is specified', function()
-    local observable = Rx.Observable.fromValue(false):all()
+    local observable = Rx.Observable.of(false):all()
     expect(observable).to.produce({{false}})
     expect(observable).to.produce({{false}})
 
 
-    observable = Rx.Observable.fromValue(true):all()
+    observable = Rx.Observable.of(true):all()
     expect(observable).to.produce({{true}})
     expect(observable).to.produce({{true}})
   end)
   end)
 end)
 end)

+ 1 - 1
tests/buffer.lua

@@ -1,6 +1,6 @@
 describe('buffer', function()
 describe('buffer', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:buffer().subscribe).to.fail()
     expect(observable:buffer().subscribe).to.fail()
   end)
   end)

+ 3 - 3
tests/combineLatest.lua

@@ -5,9 +5,9 @@ describe('combineLatest', function()
   end)
   end)
 
 
   it('calls the combinator function with all values produced from all input observables once they have all produced a value', function()
   it('calls the combinator function with all values produced from all input observables once they have all produced a value', function()
-    local observableA = Rx.Observable.fromValue('a')
-    local observableB = Rx.Observable.fromValue('b')
-    local observableC = Rx.Observable.fromValue('c')
+    local observableA = Rx.Observable.of('a')
+    local observableB = Rx.Observable.of('b')
+    local observableC = Rx.Observable.of('c')
     local combinator = spy()
     local combinator = spy()
     Rx.Observable.combineLatest(observableA, observableB, observableC, function(...) combinator(...) end):subscribe()
     Rx.Observable.combineLatest(observableA, observableB, observableC, function(...) combinator(...) end):subscribe()
     expect(combinator).to.equal({{'a', 'b', 'c'}})
     expect(combinator).to.equal({{'a', 'b', 'c'}})

+ 1 - 1
tests/compact.lua

@@ -1,6 +1,6 @@
 describe('compact', function()
 describe('compact', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:compact().subscribe).to.fail()
     expect(observable:compact().subscribe).to.fail()
   end)
   end)

+ 1 - 1
tests/concat.lua

@@ -22,7 +22,7 @@ describe('concat', function()
 
 
   it('should error if any of the sources error', function()
   it('should error if any of the sources error', function()
     local badObservable = Rx.Observable.create(function(observer) observer:onError('oh no') end)
     local badObservable = Rx.Observable.create(function(observer) observer:onError('oh no') end)
-    local observable = Rx.Observable.fromValue(1):concat(Rx.Observable.fromValue(2), badObservable)
+    local observable = Rx.Observable.of(1):concat(Rx.Observable.of(2), badObservable)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
   end)
   end)
 
 

+ 1 - 1
tests/distinct.lua

@@ -5,7 +5,7 @@ describe('distinct', function()
   end)
   end)
 
 
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:distinct().subscribe).to.fail()
     expect(observable:distinct().subscribe).to.fail()
   end)
   end)

+ 3 - 3
tests/distinctUntilChanged.lua

@@ -1,6 +1,6 @@
 describe('distinctUntilChanged', function()
 describe('distinctUntilChanged', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:distinctUntilChanged().subscribe).to.fail()
     expect(observable:distinctUntilChanged().subscribe).to.fail()
   end)
   end)
@@ -12,7 +12,7 @@ describe('distinctUntilChanged', function()
     end)
     end)
 
 
     it('produces the first value if it is nil', function()
     it('produces the first value if it is nil', function()
-      local observable = Rx.Observable.fromValue(nil):distinctUntilChanged()
+      local observable = Rx.Observable.of(nil):distinctUntilChanged()
       expect(observable).to.produce({{}})
       expect(observable).to.produce({{}})
     end)
     end)
 
 
@@ -29,7 +29,7 @@ describe('distinctUntilChanged', function()
     end)
     end)
 
 
     it('produces the first value if it is nil', function()
     it('produces the first value if it is nil', function()
-      local observable = Rx.Observable.fromValue(nil):distinctUntilChanged(function(x, y) return true end)
+      local observable = Rx.Observable.of(nil):distinctUntilChanged(function(x, y) return true end)
       expect(observable).to.produce({{}})
       expect(observable).to.produce({{}})
     end)
     end)
 
 

+ 4 - 4
tests/elementAt.lua

@@ -11,16 +11,16 @@ describe('elementAt', function()
   end)
   end)
 
 
   it('errors if no index is specified', function()
   it('errors if no index is specified', function()
-    expect(Rx.Observable.fromValue(1):elementAt().subscribe).to.fail()
+    expect(Rx.Observable.of(1):elementAt().subscribe).to.fail()
   end)
   end)
 
 
   it('produces no values if the specified index is less than one', function()
   it('produces no values if the specified index is less than one', function()
-    expect(Rx.Observable.fromValue(1):elementAt(0)).to.produce.nothing()
-    expect(Rx.Observable.fromValue(1):elementAt(-1)).to.produce.nothing()
+    expect(Rx.Observable.of(1):elementAt(0)).to.produce.nothing()
+    expect(Rx.Observable.of(1):elementAt(-1)).to.produce.nothing()
   end)
   end)
 
 
   it('produces no values if the specified index is greater than the number of elements produced by the source', function()
   it('produces no values if the specified index is greater than the number of elements produced by the source', function()
-    expect(Rx.Observable.fromValue(1):elementAt(2)).to.produce.nothing()
+    expect(Rx.Observable.of(1):elementAt(2)).to.produce.nothing()
   end)
   end)
 
 
   it('produces all values produced by the source at the specified index', function()
   it('produces all values produced by the source at the specified index', function()

+ 2 - 2
tests/filter.lua

@@ -17,14 +17,14 @@ describe('filter', function()
   end)
   end)
 
 
   it('errors when its parent errors', function()
   it('errors when its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:filter().subscribe).to.fail()
     expect(observable:filter().subscribe).to.fail()
   end)
   end)
 
 
   it('calls onError if the predicate errors', function()
   it('calls onError if the predicate errors', function()
     local onError = spy()
     local onError = spy()
-    Rx.Observable.fromValue(5):filter(error):subscribe(nil, onError, nil)
+    Rx.Observable.of(5):filter(error):subscribe(nil, onError, nil)
     expect(#onError).to.equal(1)
     expect(#onError).to.equal(1)
   end)
   end)
 end)
 end)

+ 2 - 2
tests/find.lua

@@ -1,13 +1,13 @@
 describe('find', function()
 describe('find', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:find().subscribe).to.fail()
     expect(observable:find().subscribe).to.fail()
   end)
   end)
 
 
   it('calls onError if the predicate errors', function()
   it('calls onError if the predicate errors', function()
     local onError = spy()
     local onError = spy()
-    Rx.Observable.fromValue(3):find(error):subscribe(nil, onError, nil)
+    Rx.Observable.of(3):find(error):subscribe(nil, onError, nil)
     expect(#onError).to.equal(1)
     expect(#onError).to.equal(1)
   end)
   end)
 
 

+ 1 - 1
tests/first.lua

@@ -1,6 +1,6 @@
 describe('first', function()
 describe('first', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:first().subscribe).to.fail()
     expect(observable:first().subscribe).to.fail()
   end)
   end)

+ 1 - 1
tests/flatMap.lua

@@ -1,6 +1,6 @@
 describe('flatMap', function()
 describe('flatMap', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):flatMap(function(x) return x() end)
+    local observable = Rx.Observable.of(''):flatMap(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
   end)
   end)
 
 

+ 1 - 1
tests/flatten.lua

@@ -1,6 +1,6 @@
 describe('flatten', function()
 describe('flatten', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:flatten().subscribe).to.fail()
     expect(observable:flatten().subscribe).to.fail()
   end)
   end)

+ 1 - 1
tests/last.lua

@@ -1,6 +1,6 @@
 describe('last', function()
 describe('last', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:last().subscribe).to.fail()
     expect(observable:last().subscribe).to.fail()
   end)
   end)

+ 1 - 1
tests/map.lua

@@ -1,6 +1,6 @@
 describe('map', function()
 describe('map', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:map().subscribe).to.fail()
     expect(observable:map().subscribe).to.fail()
   end)
   end)

+ 2 - 2
tests/max.lua

@@ -1,12 +1,12 @@
 describe('max', function()
 describe('max', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:max().subscribe).to.fail()
     expect(observable:max().subscribe).to.fail()
   end)
   end)
 
 
   it('produces an error if one of the values produced is a string', function()
   it('produces an error if one of the values produced is a string', function()
-    local observable = Rx.Observable.fromValue('string'):max()
+    local observable = Rx.Observable.of('string'):max()
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
   end)
   end)
 
 

+ 2 - 2
tests/min.lua

@@ -1,12 +1,12 @@
 describe('min', function()
 describe('min', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:min().subscribe).to.fail()
     expect(observable:min().subscribe).to.fail()
   end)
   end)
 
 
   it('produces an error if one of the values produced is a string', function()
   it('produces an error if one of the values produced is a string', function()
-    local observable = Rx.Observable.fromValue('string'):min()
+    local observable = Rx.Observable.of('string'):min()
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
   end)
   end)
 
 

+ 13 - 8
tests/observable.lua

@@ -14,14 +14,14 @@ describe('Observable', function()
 
 
   describe('subscribe', function()
   describe('subscribe', function()
     it('passes the first argument to _subscribe if it is a table', function()
     it('passes the first argument to _subscribe if it is a table', function()
-      local observable = Rx.Observable.fromValue()
+      local observable = Rx.Observable.of()
       local observer = Rx.Observer.create()
       local observer = Rx.Observer.create()
       local function run() observable:subscribe(observer) end
       local function run() observable:subscribe(observer) end
       expect(spy(observable, '_subscribe', run)).to.equal({{observer}})
       expect(spy(observable, '_subscribe', run)).to.equal({{observer}})
     end)
     end)
 
 
     it('creates a new Observer using the first three arguments and passes it to _subscribe if the first argument is not a table', function()
     it('creates a new Observer using the first three arguments and passes it to _subscribe if the first argument is not a table', function()
-      local observable = Rx.Observable.fromValue()
+      local observable = Rx.Observable.of()
       local a, b, c = function() end, function() end, function() end
       local a, b, c = function() end, function() end, function() end
       local function run() observable:subscribe(a, b, c) end
       local function run() observable:subscribe(a, b, c) end
       local observer = spy(observable, '_subscribe', run)[1][1]
       local observer = spy(observable, '_subscribe', run)[1][1]
@@ -59,16 +59,21 @@ describe('Observable', function()
     end)
     end)
   end)
   end)
 
 
-  describe('fromValue', function()
-    it('returns an Observable that produces the first argument and completes', function()
-      local observable = Rx.Observable.fromValue(1, 2, 3)
-      expect(observable).to.produce(1)
+  describe('of', function()
+    it('returns an Observable that produces the supplied arguments and completes', function()
+      local observable = Rx.Observable.of(1, 2, 3)
+      expect(observable).to.produce(1, 2, 3)
     end)
     end)
 
 
-    it('returns an Observable that produces nil and completes if no arguments are passed', function()
-      local observable = Rx.Observable.fromValue()
+    it('returns an Observable that produces nil and completes if nil is passed', function()
+      local observable = Rx.Observable.of(nil)
       expect(observable).to.produce(nil)
       expect(observable).to.produce(nil)
     end)
     end)
+
+    it('returns an Observable that produces nothing if no arguments are passed', function()
+      local observable = Rx.Observable.of()
+      expect(observable).to.produce.nothing()
+    end)
   end)
   end)
 
 
   describe('fromRange', function()
   describe('fromRange', function()

+ 1 - 1
tests/pack.lua

@@ -1,6 +1,6 @@
 describe('pack', function()
 describe('pack', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:pack().subscribe).to.fail()
     expect(observable:pack().subscribe).to.fail()
   end)
   end)

+ 1 - 1
tests/partition.lua

@@ -1,6 +1,6 @@
 describe('partition', function()
 describe('partition', function()
   it('errors when its parent errors', function()
   it('errors when its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:partition().subscribe).to.fail()
     expect(observable:partition().subscribe).to.fail()
   end)
   end)

+ 2 - 2
tests/pluck.lua

@@ -1,6 +1,6 @@
 describe('pluck', function()
 describe('pluck', function()
   it('returns the original observable if no key is specified', function()
   it('returns the original observable if no key is specified', function()
-    local observable = Rx.Observable.fromValue(7)
+    local observable = Rx.Observable.of(7)
     expect(observable:pluck()).to.equal(observable)
     expect(observable:pluck()).to.equal(observable)
   end)
   end)
 
 
@@ -33,6 +33,6 @@ describe('pluck', function()
 
 
   it('respects metatables', function()
   it('respects metatables', function()
     local t = setmetatable({}, {__index = {a = 'b'}})
     local t = setmetatable({}, {__index = {a = 'b'}})
-    expect(Rx.Observable.fromValue(t):pluck('a')).to.produce('b')
+    expect(Rx.Observable.of(t):pluck('a')).to.produce('b')
   end)
   end)
 end)
 end)

+ 2 - 2
tests/reduce.lua

@@ -1,6 +1,6 @@
 describe('reduce', function()
 describe('reduce', function()
   it('fails if the first argument is not a function', function()
   it('fails if the first argument is not a function', function()
-    local observable = Rx.Observable.fromValue(0)
+    local observable = Rx.Observable.of(0)
     expect(observable:reduce()).to.fail()
     expect(observable:reduce()).to.fail()
     expect(observable:reduce(1)).to.fail()
     expect(observable:reduce(1)).to.fail()
     expect(observable:reduce('')).to.fail()
     expect(observable:reduce('')).to.fail()
@@ -10,7 +10,7 @@ describe('reduce', function()
 
 
   it('uses the seed as the initial value to the accumulator', function()
   it('uses the seed as the initial value to the accumulator', function()
     local accumulator = spy()
     local accumulator = spy()
-    Rx.Observable.fromValue(3):reduce(accumulator, 4):subscribe()
+    Rx.Observable.of(3):reduce(accumulator, 4):subscribe()
     expect(accumulator[1]).to.equal({4, 3})
     expect(accumulator[1]).to.equal({4, 3})
   end)
   end)
 
 

+ 1 - 1
tests/reject.lua

@@ -17,7 +17,7 @@ describe('reject', function()
   end)
   end)
 
 
   it('errors when its parent errors', function()
   it('errors when its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:reject().subscribe).to.fail()
     expect(observable:reject().subscribe).to.fail()
   end)
   end)

+ 2 - 2
tests/scan.lua

@@ -1,6 +1,6 @@
 describe('scan', function()
 describe('scan', function()
   it('fails if the first argument is not a function', function()
   it('fails if the first argument is not a function', function()
-    local observable = Rx.Observable.fromValue(0)
+    local observable = Rx.Observable.of(0)
     expect(observable:scan()).to.fail()
     expect(observable:scan()).to.fail()
     expect(observable:scan(1)).to.fail()
     expect(observable:scan(1)).to.fail()
     expect(observable:scan('')).to.fail()
     expect(observable:scan('')).to.fail()
@@ -10,7 +10,7 @@ describe('scan', function()
 
 
   it('uses the seed as the initial value to the accumulator', function()
   it('uses the seed as the initial value to the accumulator', function()
     local accumulator = spy()
     local accumulator = spy()
-    Rx.Observable.fromValue(3):scan(accumulator, 4):subscribe()
+    Rx.Observable.of(3):scan(accumulator, 4):subscribe()
     expect(accumulator[1]).to.equal({4, 3})
     expect(accumulator[1]).to.equal({4, 3})
   end)
   end)
 
 

+ 2 - 2
tests/skip.lua

@@ -1,6 +1,6 @@
 describe('skip', function()
 describe('skip', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:skip(1).subscribe).to.fail()
     expect(observable:skip(1).subscribe).to.fail()
   end)
   end)
@@ -26,7 +26,7 @@ describe('skip', function()
   end)
   end)
 
 
   it('completes and does not fail if it skips over more values than were produced', function()
   it('completes and does not fail if it skips over more values than were produced', function()
-    local observable = Rx.Observable.fromValue(3):skip(5)
+    local observable = Rx.Observable.of(3):skip(5)
     local onNext, onError, onCompleted = observableSpy(observable)
     local onNext, onError, onCompleted = observableSpy(observable)
     expect(#onNext).to.equal(0)
     expect(#onNext).to.equal(0)
     expect(#onError).to.equal(0)
     expect(#onError).to.equal(0)

+ 3 - 3
tests/skipUntil.lua

@@ -1,12 +1,12 @@
 describe('skipUntil', function()
 describe('skipUntil', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:skipUntil(1).subscribe).to.fail()
     expect(observable:skipUntil(1).subscribe).to.fail()
   end)
   end)
 
 
   it('fails if the first argument is not an Observable', function()
   it('fails if the first argument is not an Observable', function()
-    local observable = Rx.Observable.fromValue(3)
+    local observable = Rx.Observable.of(3)
     expect(observable:skipUntil(nil)).to.fail()
     expect(observable:skipUntil(nil)).to.fail()
     expect(observable:skipUntil(0)).to.fail()
     expect(observable:skipUntil(0)).to.fail()
     expect(observable:skipUntil({})).to.fail()
     expect(observable:skipUntil({})).to.fail()
@@ -38,7 +38,7 @@ describe('skipUntil', function()
   it('produces all values if the specified observable fires immediately', function()
   it('produces all values if the specified observable fires immediately', function()
     local onNext = spy()
     local onNext = spy()
     local subject = Rx.Subject.create()
     local subject = Rx.Subject.create()
-    subject:skipUntil(Rx.Observable.fromValue(1)):subscribe(Rx.Observer.create(onNext))
+    subject:skipUntil(Rx.Observable.of(1)):subscribe(Rx.Observer.create(onNext))
     subject:onNext(1)
     subject:onNext(1)
     subject:onNext(2)
     subject:onNext(2)
     subject:onNext(3)
     subject:onNext(3)

+ 1 - 1
tests/skipWhile.lua

@@ -1,6 +1,6 @@
 describe('skipWhile', function()
 describe('skipWhile', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:skipWhile(function() end).subscribe).to.fail()
     expect(observable:skipWhile(function() end).subscribe).to.fail()
   end)
   end)

+ 4 - 4
tests/take.lua

@@ -1,17 +1,17 @@
 describe('take', function()
 describe('take', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:take(1).subscribe).to.fail()
     expect(observable:take(1).subscribe).to.fail()
   end)
   end)
 
 
   it('produces nothing if the count is zero', function()
   it('produces nothing if the count is zero', function()
-    local observable = Rx.Observable.fromValue(3):take(0)
+    local observable = Rx.Observable.of(3):take(0)
     expect(observable).to.produce.nothing()
     expect(observable).to.produce.nothing()
   end)
   end)
 
 
   it('produces nothing if the count is less than zero', function()
   it('produces nothing if the count is less than zero', function()
-    local observable = Rx.Observable.fromValue(3):take(-3)
+    local observable = Rx.Observable.of(3):take(-3)
     expect(observable).to.produce.nothing()
     expect(observable).to.produce.nothing()
   end)
   end)
 
 
@@ -26,7 +26,7 @@ describe('take', function()
   end)
   end)
 
 
   it('completes and does not fail if it takes more values than were produced', function()
   it('completes and does not fail if it takes more values than were produced', function()
-    local observable = Rx.Observable.fromValue(3):take(5)
+    local observable = Rx.Observable.of(3):take(5)
     local onNext, onError, onCompleted = observableSpy(observable)
     local onNext, onError, onCompleted = observableSpy(observable)
     expect(onNext).to.equal({{3}})
     expect(onNext).to.equal({{3}})
     expect(#onError).to.equal(0)
     expect(#onError).to.equal(0)

+ 3 - 3
tests/takeUntil.lua

@@ -1,12 +1,12 @@
 describe('takeUntil', function()
 describe('takeUntil', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:takeUntil().subscribe).to.fail()
     expect(observable:takeUntil().subscribe).to.fail()
   end)
   end)
 
 
   it('fails if the first argument is not an Observable', function()
   it('fails if the first argument is not an Observable', function()
-    local observable = Rx.Observable.fromValue(3)
+    local observable = Rx.Observable.of(3)
     expect(observable:takeUntil(nil)).to.fail()
     expect(observable:takeUntil(nil)).to.fail()
     expect(observable:takeUntil(0)).to.fail()
     expect(observable:takeUntil(0)).to.fail()
     expect(observable:takeUntil({})).to.fail()
     expect(observable:takeUntil({})).to.fail()
@@ -35,7 +35,7 @@ describe('takeUntil', function()
   it('produces no values if the specified observable fires immediately', function()
   it('produces no values if the specified observable fires immediately', function()
     local onNext = spy()
     local onNext = spy()
     local subject = Rx.Subject.create()
     local subject = Rx.Subject.create()
-    subject:takeUntil(Rx.Observable.fromValue(1)):subscribe(Rx.Observer.create(onNext))
+    subject:takeUntil(Rx.Observable.of(1)):subscribe(Rx.Observer.create(onNext))
     subject:onNext(1)
     subject:onNext(1)
     subject:onNext(2)
     subject:onNext(2)
     subject:onNext(3)
     subject:onNext(3)

+ 1 - 1
tests/takeWhile.lua

@@ -1,6 +1,6 @@
 describe('takeWhile', function()
 describe('takeWhile', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:takeWhile(function() end).subscribe).to.fail()
     expect(observable:takeWhile(function() end).subscribe).to.fail()
   end)
   end)

+ 2 - 2
tests/tap.lua

@@ -17,7 +17,7 @@ describe('tap', function()
     local onNext = spy()
     local onNext = spy()
     local onError = spy()
     local onError = spy()
     local observer = Rx.Observer.create(onNext, onError)
     local observer = Rx.Observer.create(onNext, onError)
-    Rx.Observable.fromValue(1):tap(error):subscribe(observer)
+    Rx.Observable.of(1):tap(error):subscribe(observer)
     expect(#onNext).to.equal(0)
     expect(#onNext).to.equal(0)
     expect(#onError).to.equal(1)
     expect(#onError).to.equal(1)
   end)
   end)
@@ -47,7 +47,7 @@ describe('tap', function()
   it('calls onError if the onCompleted callback errors', function()
   it('calls onError if the onCompleted callback errors', function()
     local onError = spy()
     local onError = spy()
     local onCompleted = spy()
     local onCompleted = spy()
-    Rx.Observable.fromValue(1):tap(nil, nil, error):subscribe(nil, onError, onCompleted)
+    Rx.Observable.of(1):tap(nil, nil, error):subscribe(nil, onError, onCompleted)
     expect(#onCompleted).to.equal(0)
     expect(#onCompleted).to.equal(0)
     expect(#onError).to.equal(1)
     expect(#onError).to.equal(1)
   end)
   end)

+ 2 - 2
tests/unpack.lua

@@ -1,12 +1,12 @@
 describe('unpack', function()
 describe('unpack', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:unpack().subscribe).to.fail()
     expect(observable:unpack().subscribe).to.fail()
   end)
   end)
 
 
   it('fails if the observable produces an element that is not a table', function()
   it('fails if the observable produces an element that is not a table', function()
-    expect(Rx.Observable.fromValue(3):unpack().subscribe).to.fail()
+    expect(Rx.Observable.of(3):unpack().subscribe).to.fail()
   end)
   end)
 
 
   it('produces all elements in the tables produced as multiple values', function()
   it('produces all elements in the tables produced as multiple values', function()

+ 1 - 1
tests/unwrap.lua

@@ -1,6 +1,6 @@
 describe('unwrap', function()
 describe('unwrap', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:unwrap().subscribe).to.fail()
     expect(observable:unwrap().subscribe).to.fail()
   end)
   end)

+ 1 - 1
tests/window.lua

@@ -1,6 +1,6 @@
 describe('window', function()
 describe('window', function()
   it('produces an error if its parent errors', function()
   it('produces an error if its parent errors', function()
-    local observable = Rx.Observable.fromValue(''):map(function(x) return x() end)
+    local observable = Rx.Observable.of(''):map(function(x) return x() end)
     expect(observable.subscribe).to.fail()
     expect(observable.subscribe).to.fail()
     expect(observable:window().subscribe).to.fail()
     expect(observable:window().subscribe).to.fail()
   end)
   end)