Last active
December 12, 2015 05:19
-
-
Save OsQu/4721193 to your computer and use it in GitHub Desktop.
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
# Poller.coffee | |
class Poller | |
constructor: -> | |
@stream = new Bacon.Bus() | |
start: -> | |
@interval = setInterval pollPhoneLocation, 5 * 60 | |
stop: -> | |
clearInterval @interval | |
pollPhoneLocation = => | |
# Joku vitun hieno kutsu sinne backendii | |
backendLibrary.getPhoneLocation (event) => | |
# Probably callback has some kind of event | |
@stream.push event | |
# Map.coffee | |
class Map | |
register: (stream) -> | |
@unsubscribe = stream.filter((event) -> event.type == "map-update").onValue (event) => | |
updateMap(event) | |
mapUpdate = (event) -> | |
# So some magic map updating and blow the universe! | |
dispose: -> # Call this when you want to free Map.. Front end developing so have to be careful about memory leaks | |
@unsubscribe() | |
#SomeOtherThing.coffee | |
class SomeOtherThing | |
register: (stream) -> | |
@unsubscribe = stream.filter((event) -> event.type == "someOtherThing").onValue (event) => | |
youGotThePoint(event) | |
# The old place where all the code was before | |
poller = new Poller() | |
map = new Map() | |
someOtherThing = new someOtherThing() | |
map.register poller.stream | |
someOtherThing.register poller.stream | |
poller.start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment