Skip to content

Instantly share code, notes, and snippets.

@buckle2000
Last active February 6, 2017 18:01
Show Gist options
  • Save buckle2000/0bc553e6aa9f3ae85b932b4a87ff07a1 to your computer and use it in GitHub Desktop.
Save buckle2000/0bc553e6aa9f3ae85b932b4a87ff07a1 to your computer and use it in GitHub Desktop.
subscribe_last for RxLua.Observable
local rx = require("rx")
rx.Observable.subscribe_last = function(self, callback)
local original_onNext = self.onNext
self.onNext = function(self, ...)
original_onNext(self, ...)
callback(...)
end
return rx.Subscription.create(function()
self.onNext = original_onNext
end)
end
rx = require "rx"
rx.Observable.subscribe_last = (callback) =>
original_onNext = @onNext
@onNext = (...) =>
original_onNext @, ...
callback ...
rx.Subscription.create ->
-- undo
@onNext = original_onNext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment