JuliaGizmos / Vue.jl

a Julia wrapper for Vue.js
Other
21 stars 8 forks source link

WIP: use newer API #5

Closed shashi closed 6 years ago

shashi commented 6 years ago

in an attempt to get this to work, I have removed the mention of show_cb thing.

I removed some of the explicit SystemJS code, and the callback and dependencies kwargs, as it turns out you can now add them after the Widget object has been created (but before it gets rendered). Thanks to vue now returning the widget object!

Demo:

screenshot from 2018-02-12 20-10-46

shashi commented 6 years ago

I see Vue.component("vue-slider", VueSlider) is required to be run before Vue instance is created but after vue has been loaded... I thought of wrapping the vue widget with another widget which sets up the component but then you'd have to have it forward all the observables as well... So I think it's easiest to bring this one back!

shashi commented 6 years ago

Oh wait, there's a beforeCreate lifecycle handler :D

shashi commented 6 years ago

@JobJob solved the hooking in issue by delaying creating the vue instance till the next event loop tick!

Now this WORKS! --

using Vue

function slider(rng)
    w = vue(dom"div"(
        dom"vue-slider[ref=slider, v-model=value]"()
      ), ["value" => Observable{Any}(first(rng))]
    )
    on(identity, w["value"])
    import!(w, "https://nightcatsama.github.io/vue-slider-component/dist/index.js")
    onimport(w, @js function (Vue, vueSlider)
            Vue.component("vue-slider", vueSlider)

    end)
    w
end