sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

Have any property of worker.sql.js to check datebase is ready?

Open lon91ong opened this issue 6 years ago • 1 comments

I want to know the status of my web worker.sql. No demo show me the way. Anyone can help?

lon91ong avatar Apr 14 '19 06:04 lon91ong

In the source code (for worker version), there is a postMessage ready event. Are you calling open and listening on the browser/client for messages back?

src/worker.coffee

sqlModuleReady.then ->
            data  = event['data']
            switch data?['action']
                when 'open'
                    buff = data['buffer']
                    createDb (if buff then new Uint8Array(buff) else undefined)
                    postMessage
                        'id': data['id']
                        'ready': true

I use a seperate message passing library like callbag-subject or worker-rpc etc, with an observable/subscribe method to talk back and forth. It allows notifying the browser/client without polling.

sbrichardson avatar Nov 21 '19 21:11 sbrichardson