Sha256: 90d9abacee5a12a0b2825508f1fc65a283feb7db8f876624c7cb7ed6abdecccd
Contents?: true
Size: 754 Bytes
Versions: 22
Compression:
Stored size: 754 Bytes
Contents
module Isomorfeus module BrowserStoreApi def promise_get(key) Promise.new.resolve(get(key)) end def promise_set(key, value) Promise.new.resolve(set(key, value)) end def promise_delete(key) Promise.new.resolve(delete(key)) end def promise_clear Promise.new.resolve(clear) end def subscribe(&block) key = SecureRandom.uuid subscribers[key] = block key end def unsubscribe(key) subscribers.delete(key) nil end def notify_subscribers return if subscribers.empty? after 0 do subscribers.each_value do |block| block.call end end end def subscribers @subscribers ||= {} end end end
Version data entries
22 entries across 22 versions & 1 rubygems