Last active
February 6, 2017 18:01
-
-
Save buckle2000/0bc553e6aa9f3ae85b932b4a87ff07a1 to your computer and use it in GitHub Desktop.
subscribe_last for RxLua.Observable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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