mrmiguu / coco

Golang WebAssembly Framework
MIT License
110 stars 4 forks source link

Modifying a non-pointer receiver in example #6

Open ghost opened 5 years ago

ghost commented 5 years ago

https://github.com/mrmiguu/coco/blob/e51861ba64cb68c40c4abda2cce111872c47fd30/example/Count.go#L19

The example is modifying a non-pointer receiver's field. It seems like a bug.

mrmiguu commented 5 years ago

The aim here was to simulate a sort of top-down functional approach similar to React in how it accesses state at a field-level but mutates it indirectly:

this.setState({ Cocos: [...this.state.Cocos, '🥥'] })

But I'm more than open to considering a pointer style of mutation that is more Vue-like and 2-way bound. That might even feel more idiomatic in Go. Thanks for pointing this out!