@missive/ndex
Version:
Ndex is an indexedDB wrapper
24 lines (18 loc) • 700 B
text/coffeescript
# Connection will be injected through blob
init = ({ name, migrations }) ->
= new Connection(name, migrations)
handleLogging = ->
.logging.handleLog = (args) ->
postMessage(method: 'handleLog', args: args)
self.onmessage = (e) =>
data = e.data
data = [data] unless Array.isArray(data)
data.forEach (datum) =>
{ id, method, args } = datum
# Intercept known methods
if typeof this[method] is 'function'
return this[method](args)
# Unknown methods are relayed to
[method].apply(, args)
.then (data) -> postMessage(id: id, resolve: data)
.catch (data) -> postMessage(id: id, reject: data)