klarkc / pure-vue

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

Add setup POC #1

Closed klarkc closed 2 years ago

klarkc commented 3 years ago

I am looking for how purscript effect system could work with vue setup hook in a non intrusive way.

klarkc commented 3 years ago

My guess is that vue "ref" function is effectful, so this gonna be helpful https://book.purescript.org/chapter10.html#effectful-functions

klarkc commented 3 years ago

Source of inspiration of how to deal with hooks in the purs context:

https://gist.github.com/i-am-the-slime/eb0f9168e17277b4ff37de25dfe6816e

https://github.com/jonasbuntinx/purescript-react-realworld/

klarkc commented 2 years ago

Effectful example in POC: 4d91e4c831b239fb5228afdca0a6e541c79a456a

klarkc commented 2 years ago

My guess is that vue "ref" function is effectful, so this gonna be helpful https://book.purescript.org/chapter10.html#effectful-functions

The ref function is not side-effect free because it uses reactive, which uses a effectful function mutating reactiveMap.

klarkc commented 2 years ago

Fixed on 8f0bd65f74990ab555f93222bc4f52518daf64fa, changing Ref logic, it will be just a reference to the reactive object to be used inside Effect monad.

klarkc commented 2 years ago

There still a problem, how set/get would know how to address the ref. The only solution that I think is to have side-effects on ref, requiring the use of Effect monad

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

klarkc commented 2 years ago

Done in 7ff1b2a261a3268d07bc3f5e847d6cf8c2e2623b