-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from HuckRidgeSW/wasm
WASM support
- Loading branch information
Showing
38 changed files
with
4,593 additions
and
2,589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
.*.sw? | ||
*.bak | ||
Session*.vim | ||
build | ||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,55 @@ | ||
package hvue | ||
|
||
import "github.com/gopherjs/gopherjs/js" | ||
import ( | ||
"github.com/gopherjs/gopherwasm/js" | ||
) | ||
|
||
// Computed defines name as a computed property. Note that name *must not* be | ||
// set in data for this to work. It's probably best if it's not even a slot | ||
// in the struct. Only access it via vm.Get. You could also create an | ||
// accessor; see the 04-computed-with-setter example. | ||
// | ||
// Computed functions require synchronous functions that can return values to | ||
// Vue. Go/wasm cannot support either of those things just yet. So currently | ||
// this function just panics. | ||
// | ||
// Use a watcher instead. | ||
func Computed(name string, f func(vm *VM) interface{}) ComponentOption { | ||
return func(c *Config) { | ||
if c.Computed == js.Undefined { | ||
c.Computed = NewObject() | ||
} | ||
c.Computed.Set(name, jsCallWithVM(f)) | ||
} | ||
panic("Computed not supported") | ||
// return func(c *Config) { | ||
// if c.Computed() == js.Undefined() { | ||
// c.SetComputed(NewObject()) | ||
// } | ||
// c.Computed().Set(name, jsCallWithVM(f)) | ||
// } | ||
} | ||
|
||
// ComputedWithGetSet defines name as a computed property with explicit get & | ||
// set. Note that name *must not* be set in data for this to work. It's | ||
// probably best if it's not even a slot in the struct. Only access it via | ||
// vm.Get/Set. You could create an accessor; see the 04-computed-with-setter | ||
// example. | ||
func ComputedWithGetSet(name string, get func(vm *VM) interface{}, set func(vm *VM, newValue *js.Object)) ComponentOption { | ||
return func(c *Config) { | ||
if c.Computed == js.Undefined { | ||
c.Computed = NewObject() | ||
} | ||
c.Computed.Set(name, | ||
js.M{ | ||
"get": jsCallWithVM(get), | ||
"set": js.MakeFunc( | ||
func(this *js.Object, args []*js.Object) interface{} { | ||
vm := &VM{Object: this} | ||
set(vm, args[0]) | ||
return nil | ||
})}) | ||
c.Setters.Set(name, true) | ||
} | ||
// | ||
// Computed functions require synchronous functions that can return values to | ||
// Vue. Go/wasm cannot support either of those things just yet. So currently | ||
// this function just panics. | ||
// | ||
// Use a watcher instead. | ||
func ComputedWithGetSet(name string, get func(vm *VM) interface{}, set func(vm *VM, newValue js.Value)) ComponentOption { | ||
panic("ComputedWithGetSet not supported") | ||
// return func(c *Config) { | ||
// if c.Computed() == js.Undefined() { | ||
// c.SetComputed(NewObject()) | ||
// } | ||
// c.Computed().Set(name, | ||
// map[string]interface{}{ | ||
// "get": jsCallWithVM(get), | ||
// "set": NewCallback( | ||
// func(this js.Value, args []js.Value) interface{} { | ||
// vm := &VM{Value: this} | ||
// set(vm, args[0]) | ||
// return nil | ||
// })}) | ||
// c.Setters().Set(name, true) | ||
// } | ||
} |
Oops, something went wrong.