fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.16k stars 122 forks source link

Allow Incremental Adoption of Fabulous #279

Closed slang25 closed 5 years ago

slang25 commented 5 years ago

Currently Fabulous is an all or nothing framework, I would like to add a mode that is closely aligned with the "Half Elmish" (static views) approach so that you could take an existing Xamarin application and start to incrementally adopt Fabulous, with the following requirement:

You would be expected to construct pages yourself and grab the view models from Fabulous and set the datacontext. The way you'd get the view models, I'm not completely sure of at the moment. Perhaps you are returned a function that can get the views by name.

This would allow people with existing Xamarin applications to dip their toes into adopting this library, possibly view model at a time. In addition, the developers don't give up control to Fabulous, which means they have more control over architecture, can use native views in places etc...

I'm happy to work on the implementation and have something here I'm using in my current project. I might post some WIP code so that you can see what it would look like.

My current project also combines this with a message bus to subscribe to state changes (with a selector to part of the state) and publish method, this is wrapped up in a type to be consumed from C#. I think that this would be overkill for Fabulous, and can be implemented on-top of the current framework with no change. Just thought I would give you the full context of what I'm doing.

Let me know your thoughts on this.

dsyme commented 5 years ago

@slang25 Do you think you could iterate on the existing half-elmish support? It is possible what you need is basically already there, just you might have to pull apart the bit where the view model is added to the page.

We would accept PRs that support the half-elmish support, document it and improve it.

slang25 commented 5 years ago

I think I should be able to, but I'm not completely sure how I'm going to do it. I'll update here once I've made progress.

dsyme commented 5 years ago

Another approach to incremental adoption would be to show how to use (full-Elmish) Fabulous for a single page or control in a larger application. There's no really fundamental reason why we can't do this I think, though some adjustments will be needed to allow it to happen.

TimLariviere commented 5 years ago

The half-elmish approach Fabulous.StaticView has been marked as "Not actively maintained" and has been separated from the full-elmish approach Fabulous.XamarinForms

So no function or other thing to ease the transition between Fabulous.StaticView and Fabulous.XamarinForms will be added.