forked from fabioberger/chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.go
More file actions
39 lines (32 loc) · 750 Bytes
/
storage.go
File metadata and controls
39 lines (32 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package chrome
import "github.com/gopherjs/gopherjs/js"
type Storage struct {
o *js.Object
Sync *js.Object
Local *js.Object
Managed *js.Object
}
func NewStorage(storageObj *js.Object) *Storage {
s := new(Storage)
s.o = storageObj
if s.o.String() != "undefined" {
s.Sync = storageObj.Get("sync")
s.Local = storageObj.Get("local")
s.Managed = storageObj.Get("managed")
}
return s
}
/*
* Types
*/
type StorageChange struct {
OldValue interface{} `js:"oldValue"`
NewValue interface{} `js:"newValue"`
}
/*
* Events
*/
// OnChanged fired when one or more items change.
func (s *Storage) OnChanged(callback func(changes map[string]StorageChange, areaName string)) {
s.o.Get("onChanged").Call("addListener", callback)
}