Skip to content

Commit

Permalink
Merge f3d00e6 into 16edbf9
Browse files Browse the repository at this point in the history
  • Loading branch information
starwing committed Jun 21, 2020
2 parents 16edbf9 + f3d00e6 commit fad56d6
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 13 deletions.
12 changes: 6 additions & 6 deletions rx.lua
Expand Up @@ -5,7 +5,7 @@
local util = {}

util.pack = table.pack or function(...) return { n = select('#', ...), ... } end
util.unpack = table.unpack or unpack
util.unpack = table.unpack or _G.unpack
util.eq = function(x, y) return x == y end
util.noop = function() end
util.identity = function(x) return x end
Expand Down Expand Up @@ -133,7 +133,7 @@ end

--- Returns an Observable that never produces values and never completes.
function Observable.never()
return Observable.create(function(observer) end)
return Observable.create(function() end)
end

--- Returns an Observable that immediately produces an error.
Expand Down Expand Up @@ -657,8 +657,6 @@ function Observable:debounce(time, scheduler)

local function wrap(key)
return function(...)
local value = util.pack(...)

if debounced[key] then
debounced[key]:unsubscribe()
end
Expand Down Expand Up @@ -1829,6 +1827,7 @@ function Observable.zip(...)
table.insert(values[i], value)
values[i].n = values[i].n + 1

-- luacheck: ignore i
local ready = true
for i = 1, count do
if values[i].n == 0 then
Expand Down Expand Up @@ -1890,6 +1889,7 @@ end
--- Schedules a function to be run on the scheduler. It is executed immediately.
-- @arg {function} action - The function to execute.
function ImmediateScheduler:schedule(action)
local _ = self
action()
end

Expand Down Expand Up @@ -1993,8 +1993,8 @@ end
-- @arg {number=0} delay - The delay, in milliseconds.
-- @returns {Subscription}
function TimeoutScheduler:schedule(action, delay, ...)
local _ = self
local timer = require 'timer'
local subscription
local handle = timer.setTimeout(delay, action, ...)
return Subscription.create(function()
timer.clearTimeout(handle)
Expand Down Expand Up @@ -2315,4 +2315,4 @@ return {
AsyncSubject = AsyncSubject,
BehaviorSubject = BehaviorSubject,
ReplaySubject = ReplaySubject
}
}
3 changes: 2 additions & 1 deletion src/observable.lua
@@ -1,3 +1,4 @@
local Observer = require 'observer'
local util = require 'util'

--- @class Observable
Expand Down Expand Up @@ -38,7 +39,7 @@ end

--- Returns an Observable that never produces values and never completes.
function Observable.never()
return Observable.create(function(observer) end)
return Observable.create(function() end)
end

--- Returns an Observable that immediately produces an error.
Expand Down
1 change: 1 addition & 0 deletions src/operators/amb.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'

--- Given a set of Observables, produces values from only the first one to produce a value.
-- @arg {Observable...} observables
Expand Down
1 change: 1 addition & 0 deletions src/operators/combineLatest.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns a new Observable that runs a combinator function on the most recent values from a set
Expand Down
2 changes: 0 additions & 2 deletions src/operators/debounce.lua
Expand Up @@ -16,8 +16,6 @@ function Observable:debounce(time, scheduler)

local function wrap(key)
return function(...)
local value = util.pack(...)

if debounced[key] then
debounced[key]:unsubscribe()
end
Expand Down
2 changes: 1 addition & 1 deletion src/operators/flatten.lua
@@ -1,5 +1,5 @@
local Observable = require 'observable'
local util = require 'util'
local Subscription = require 'subscription'

--- Returns a new Observable that subscribes to the Observables produced by the original and
-- produces their values.
Expand Down
1 change: 1 addition & 0 deletions src/operators/merge.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'

--- Returns a new Observable that produces the values produced by all the specified Observables in
-- the order they are produced.
Expand Down
1 change: 1 addition & 0 deletions src/operators/sample.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns a new Observable that produces its most recent value every time the specified observable
Expand Down
1 change: 1 addition & 0 deletions src/operators/switch.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'

--- Given an Observable that produces Observables, returns an Observable that produces the values
-- produced by the most recently produced Observable.
Expand Down
1 change: 1 addition & 0 deletions src/operators/with.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns an Observable that produces values from the original along with the most recently
Expand Down
2 changes: 2 additions & 0 deletions src/operators/zip.lua
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns an Observable that merges the values produced by the source Observables by grouping them
Expand Down Expand Up @@ -26,6 +27,7 @@ function Observable.zip(...)
table.insert(values[i], value)
values[i].n = values[i].n + 1

-- luacheck: ignore i
local ready = true
for i = 1, count do
if values[i].n == 0 then
Expand Down
1 change: 1 addition & 0 deletions src/schedulers/immediatescheduler.lua
Expand Up @@ -15,6 +15,7 @@ end
--- Schedules a function to be run on the scheduler. It is executed immediately.
-- @arg {function} action - The function to execute.
function ImmediateScheduler:schedule(action)
local _ = self
action()
end

Expand Down
3 changes: 2 additions & 1 deletion src/schedulers/timeoutscheduler.lua
@@ -1,4 +1,5 @@
local Subscription = require 'subscription'
local util = require 'util'

--- @class TimeoutScheduler
-- @description A scheduler that uses luvit's timer library to schedule events on an event loop.
Expand All @@ -17,8 +18,8 @@ end
-- @arg {number=0} delay - The delay, in milliseconds.
-- @returns {Subscription}
function TimeoutScheduler:schedule(action, delay, ...)
local _ = self
local timer = require 'timer'
local subscription
local handle = timer.setTimeout(delay, action, ...)
return Subscription.create(function()
timer.clearTimeout(handle)
Expand Down
2 changes: 1 addition & 1 deletion src/util.lua
@@ -1,7 +1,7 @@
local util = {}

util.pack = table.pack or function(...) return { n = select('#', ...), ... } end
util.unpack = table.unpack or unpack
util.unpack = table.unpack or _G.unpack
util.eq = function(x, y) return x == y end
util.noop = function() end
util.identity = function(x) return x end
Expand Down
2 changes: 1 addition & 1 deletion tools/build.lua
Expand Up @@ -136,6 +136,6 @@ end
local file = io.open(destination, 'w')

if file then
file:write(table.concat(components, ''))
file:write(table.concat(components, ''), "\n")
file:close()
end

0 comments on commit fad56d6

Please sign in to comment.