Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 19d6da4

Browse files
committed
redo bindings for vue.filter
1 parent 399ffa2 commit 19d6da4

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

‎filter.go‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@ import (
44
"github.com/gopherjs/gopherjs/js"
55
)
66

7-
type Filter struct {
8-
*js.Object
9-
Read interface{} `js:"read"`
10-
Write interface{} `js:"write"`
11-
}
7+
// Filter return interface{} to utilize GopherJS type convertion automatically
8+
type Filter func(oldValue *js.Object) (newValue interface{})
129

1310
// using interface{} type here to utilize GopherJS type convertion automatically
14-
func NewFilter(readerfn interface{}) *Filter {
15-
f := &Filter{
16-
Object: js.Global.Get("Object").New(),
17-
}
18-
f.Read = readerfn
19-
return f
11+
func NewFilter(fn func(oldValue *js.Object) (newValue interface{})) Filter {
12+
return Filter(fn)
2013
}
2114

22-
func (f *Filter) Register(name string) {
23-
vue.Call("filter", name, f.Object)
15+
func (f Filter) Register(name string) {
16+
vue.Call("filter", name, f)
2417
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /