store_wasm.mx raw

   1  //:build wasm
   2  
   3  package store
   4  
   5  import (
   6  	"git.smesh.lol/musiquay/web/common/jsbridge/callback"
   7  	"unsafe"
   8  )
   9  
  10  //:wasmimport bridge store_worker_on_message
  11  func wasmWorkerOnMessage(cbID int32)
  12  
  13  //:wasmimport bridge store_worker_post
  14  func wasmWorkerPost(ptr *byte, length int32, capacity int32)
  15  
  16  //:wasmimport bridge store_worker_set_timeout
  17  func wasmWorkerSetTimeout(ms int32, cbID int32) (n int32)
  18  
  19  //:wasmimport bridge store_worker_clear_timeout
  20  func wasmWorkerClearTimeout(handle int32)
  21  
  22  //:wasmimport bridge store_worker_now_seconds
  23  func wasmWorkerNowSeconds() (n int64)
  24  
  25  func WorkerOnMessage(fn func(msg string)) {
  26  	wasmWorkerOnMessage(callback.RegisterS(fn))
  27  }
  28  
  29  func WorkerPost(msg string) {
  30  	wasmWorkerPost(unsafe.StringData(msg), int32(len(msg)), int32(len(msg)))
  31  }
  32  
  33  func WorkerSetTimeout(ms int32, fn func()) (n int32) {
  34  	return wasmWorkerSetTimeout(ms, callback.Register0Once(fn))
  35  }
  36  
  37  func WorkerClearTimeout(handle int32) { wasmWorkerClearTimeout(handle) }
  38  func WorkerNowSeconds() (n int64) { return wasmWorkerNowSeconds() }
  39