HuckRidgeSW / hvue

A GopherJS & go/wasm binding for Vue.js
MIT License
49 stars 10 forks source link

go/wasm support #10

Closed HuckRidgeSW closed 4 years ago

HuckRidgeSW commented 6 years ago

I've started work on go/wasm support. See the wasm branch, here.

HuckRidgeSW commented 6 years ago

Current usage instructions:

  1. cd path/to/hvue
  2. go run examples/server/main.go
  3. Navigate to http://localhost:8081/examples/01-introduction/
HuckRidgeSW commented 6 years ago

Examples through 06 work in GopherJS and wasm.

wasm doesn't have synchronous function calls from JS to wasm, so right now hvue.Computed() and friends just panic. In the examples I simulated it via hvue.Watch().

Oh and I added hvue.Watch().

Updated the README in the wasm branch with usage instructions. See https://github.com/HuckRidgeSW/hvue/blob/wasm/README.md.

ghost commented 6 years ago

can you check this ? I dont get any errors, but get nothing in the web browser..

Makefile:


LIB=github.com/HuckRidgeSW/hvue
LIB_FSPATH=$(GOPATH)/src/$(LIB)

print:
    @echo

    @echo Badwolf LIB  -
    @echo LIB :$(LIB)
    @echo LIB_FSPATH  : $(LIB_FSPATH)
    #cd $(LIB_FSPATH) && ls -al 
    @echo

    @echo

dep:
    go get -u $(LIB)
    cd  $(LIB_FSPATH) && git checkout wasm

    go get github.com/gopherjs/gopherwasm

code:
    code $(LIB_FSPATH)

server-run:
    echo "var hvue_wasm = true;" > $(LIB_FSPATH)/examples/maybe_wasm.js
    cd $(LIB_FSPATH)/examples/server && go run main.go

client-run:
    cd $(LIB_FSPATH)/examples/01-introduction && GOARCH=wasm GOOS=js go build -o 01-introduction.wasm main.go # compile wasm

    # open: http://localhost:8081/examples/01-introduction/
HuckRidgeSW commented 6 years ago

go get only gets master:

% GOPATH=/tmp/hvue-test
% go get github.com/huckridgesw/hvue
% cd /tmp/hvue-test/src/github.com/huckridgesw/hvue
% git branch --list
* master

Then you need git checkout --track origin/wasm:

% git checkout --track origin/wasm
% git branch --list
  master
* wasm

(I'll update the README. Sorry about that.) (Edit: done.)

Also you need to run the server from the hvue directory:

cd $(LIB_FSPATH) && go run examples/server/main.go

Did you check your browser console for error messages? I would've expected that you'd get 404s for everything, run the way you had it.

theclapp commented 6 years ago

Example 07 updated.

ghost commented 6 years ago

thanks @HuckRidgeSW that fixed it.

maybe include a Makefile so its clear how to get going.

Anyway Its funny when the examples load in the web GUI. YOu see the template and then about 1 second later it fills in the data. Pretty interesting stuff. The 2 second is the time for the WASM code to be interpreted it seems.

HuckRidgeSW commented 6 years ago

Anyway Its funny when the examples load in the web GUI. YOu see the template and then about 1 second later it fills in the data.

Yeah, that's something libraries like this (that is, Vue) see a lot. Angular had some way around it (I forget what, it's been a while); Vue may too, but I don't know.

HuckRidgeSW commented 6 years ago

Finished converting the last example, 08-directives, tonight. All done. 🎉

ghost commented 6 years ago

Great stuff. Very useful for making SPA and actually understand what's going on :)

On Wed, 12 Sep 2018, 03:38 Larry Clapp, notifications@github.com wrote:

Finished converting the last example, 08-directives, tonight. All done. 🎉

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HuckRidgeSW/hvue/issues/10#issuecomment-420482500, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwuIfAdbVjdW6p53FUY6CWjOV-5r8ks5uaGWigaJpZM4WW744 .

ghost commented 6 years ago

This is able to be closed now

HuckRidgeSW commented 6 years ago

I'd still like to a) tag the current master in some way ("v1", probably), and obviously b) merge to master.

Also I'd like to update the examples. The Vue Guide has moved on, too, and some of the examples have changed. I may open a separate ticket for that, though.

HuckRidgeSW commented 6 years ago

Closed by #11.