klarkc / pure-vue

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

Add a render side-effect free example #4

Closed klarkc closed 2 years ago

klarkc commented 2 years ago

I'm still considering this composition api approach, I'm seeing that composition api hides a lot of side-effects

Originally posted by @klarkc in https://github.com/klarkc/pure-vue/issues/1#issuecomment-1062332734

We'll try to create a simple side-effect-free component with a render function instead of setup hook (which is not side-effect free)

klarkc commented 2 years ago

From the top of my head

main.purs

```hs {- main.purs -} module Main where import Prelude import PureVue (VNodeChild, mount) import PureVue (createAppRender) as createApp import PureVue.HTML as H data Data = Data { message: String } render :: Data -> VNodeChild render Data { message } = H.div message main :: Effect Unit main = do app <- createApp (Data "Hello World") render discard $ mount app "#app" ```

index.html

```html

```

klarkc commented 2 years ago

Using template instead of render function:

main.purs

```purs {- main.purs -} module Main where import Prelude import PureVue (createApp, mount) data Data = Data { message: String } main :: Effect Unit main = do let data = Data "Hello World" template = "

{{ message }}
" app <- createApp data template discard $ mount app "#app" ```

index.html

```html

```

klarkc commented 2 years ago

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