klarkc / pure-vue

It's Vue, it's PureScript. Simple as that.
MIT License
18 stars 0 forks source link

Implement ref example #2

Closed klarkc closed 2 years ago

klarkc commented 3 years ago

As a proof of concept, let's try to foreign import vue ref function and use it inside purescript code that exports a setup hook.

Something like this:

main.purs

```purs {- main.purs -} module Main where import Prelude import PureVue (Ref, ref) setup = { message: ref "Hello world" } ```

index.js

```js // index.js import { setup } from 'main.purs'; // if not possible: import { setup } from 'main.js'; createApp({ component: { template: "

{{message}}
", setup } }).mount('#app'); ```

Blocked by purescript/purescript#3791

klarkc commented 3 years ago

Related #1

klarkc commented 3 years ago

Probably a better approach using createApp:

main.purs

```purs {- main.purs -} module Main where import Prelude import PureVue (ref, createApp) main :: Effect Unit main = void $ createApp { el: "#app". , template: "

{{message}}
" , setup: \_ -> { message: ref "Hello world" } } ```

index.html

```html

```

klarkc commented 2 years ago

We decided to go with https://github.com/klarkc/pure-vue/issues/1