Open Lanayx opened 5 years ago
Hmm, the plan is indeed to stay as close to Vue components as possible, but not necessarily imitating the syntax. Right now the proposed syntax ☝️ may be complicated in F# as it forces you to declare records for the methods, the data, the props, child components... the situation may change with the new anonymous records but we still need to see how they work in Fable.
The model-update(-view) pattern is not the whole Elmish (this would also include the dispatching, commands, subscriptions) but I think it's a simple structure for components that most of the people get very quickly. And it's nice to use a union type for the Vue methods in order to enable pattern matching to discriminate incoming messages.
In any case, this is the time to explore and see which API works best. So it can be a good idea to implement a couple of ways to write components and let users give their feedback :)
Thanks for the response! My initiative of imitating syntax is based on the question - how will fable look like to vue developers? And with current implementation with messages, I feel that it looks quite unfamiliar for them and there are some problems as well: 1) Many times in vue components we don't use methods / state at all. Therefore I'd want to make each of them optional 2) Quite often you call one method from another, or method from hook, with DU you'll have to extract common function 3) Very often methods don't need parameters and don't mutate state, instead they mutate Vuex, while data is displayed also with Vuex and computed properties.
I know that many functional programmers like elmish, but if I wanted to use elmish, I wouldn't use Vue.js at all. Therefore I want to suggest a component concept, that will be familiar to any Vue.js programmer.