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 6f92220

Browse files
committed
add vue.Filter
1 parent 9a49602 commit 6f92220

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

‎extra.go‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package vue
22

3-
import (
4-
"github.com/gopherjs/gopherjs/js"
5-
)
6-
7-
func Filter(name string, fn func(*js.Object) *js.Object) {
8-
vue.Call("filter", name, fn)
9-
}
10-
113
// Vue.partial( id, [definition] )
124
// id String
135
// definition String | Node optional

‎filter.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package vue
2+
3+
import (
4+
"github.com/gopherjs/gopherjs/js"
5+
)
6+
7+
type Filter struct {
8+
*js.Object
9+
Read interface{} `js:"read"`
10+
Write interface{} `js:"write"`
11+
// Read func(vm *ViewModel, args []*js.Object) *js.Object `js:"read"`
12+
// Write func(vm *ViewModel, args []*js.Object) *js.Object `js:"write"`
13+
}
14+
15+
func NewFilter(read func(val *js.Object) *js.Object) *Filter {
16+
f := &Filter{
17+
Object: js.Global.Get("Object").New(),
18+
}
19+
f.Read = read
20+
return f
21+
}
22+
23+
func (f *Filter) Register(name string) {
24+
vue.Call("filter", name, f.Object)
25+
}

0 commit comments

Comments
(0)

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