Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation/examples #8

Open
cmeeren opened this issue Nov 8, 2017 · 5 comments
Open

Documentation/examples #8

cmeeren opened this issue Nov 8, 2017 · 5 comments

Comments

@cmeeren
Copy link

cmeeren commented Nov 8, 2017

I'm intrigued by this concept, although I'm at a bit of a loss as to how it should be used, not least because Gjallarhorn seems to be mutable at its core and Gjallarhorn.Bindable talks about a "fully immutable data model".

Could you provide or link to any documentation or examples? (I've seen the API reference, and it doesn't really explain how to use it.)

@FoggyFinder
Copy link
Collaborator

You can find some examples here and there is a very great article

Christmas Trees in WPF, 2016 Edition

but API was changed so some function has different names.

@cmeeren
Copy link
Author

cmeeren commented Nov 8, 2017

Thanks. While intriguing, the samples were complex enough (contained so many nontrivial, unexplained concepts) that I'll have to wait for proper documentation before I delve further into this.

@FoggyFinder
Copy link
Collaborator

FoggyFinder commented Nov 8, 2017

@cmeeren It's really much simpler than it would appear at first sight.
Just curious what would you like to see at the documentation?

Btw, I saw in your profile the Yarni - It seems like you already know concept (cause as I know Redux was inspired by Elm). So I really can't understand what exactly is causing you difficulties.

@cmeeren
Copy link
Author

cmeeren commented Nov 8, 2017

I understand the basic concepts, and I'm sure the rest is simpler than it appears at first sight, but without documentation to set the record straight, I only have "first sight" and my own guesses to go on. Some general things I'm unsure about:

  • The binding model (usage of Component.create)
  • The role of Framework.application
  • Framework.CreateApplicationInfo and CreateApp and why these are used in the Android project instead of e.g. an App class, as is normal with Xamarin.Forms
  • What is Nav
  • How to to structure the state in a data-driven app where the state doesn't consist of easily defined components like Tree/Forest (I use redux-like architecture with one state tree and one reducer, partitioned into sub-states/reducers for convenience but still inherently coupled and defined in one place)
  • How to handle side-effects like persistence, HTTP requests, navigation, user dialogs, etc.
  • Exactly how opinionated Gjallarhorn.Bindable is, i.e., how much of the samples is mandatory, how much is best practices (and more importantly why), and how much is just an example of one way to do things

Slight tangent: I'm also unsure of if/how Gjallarhorn.Bindable has fixed a really annoying problem I have with my current redux-based Xamarin.Forms app: I have the text values of all Entry views in the store so I can control these values (prefill values, clear password fields after successful password change, etc.) and do other logic based off them (enable/disable submit buttons, show validation messages, etc.), but that means every character typed into a text field (based on Entry.TextChanged) goes through the entire redux loop, ultimately resulting in Entry.Text being set programatically (directly or through updating the BindingContext to a new immutable view model, I'm doing the latter) to the value the user just typed. In addition to some slowness, this causes problems since by updating Entry.Text, we're potentially triggering TextChanged again (if the user typed another character before the update loop completed, which is entirely possible), potentially resulting in an infinite loop where the value is changed back and forth. (I've "solved" this by wrapping the TextChanged handlers that dispatch actions in functions that only proceed if a mutable bool update field in the codebehind is false, and I set this to true before changing the BindingContext to the new VM and restore it to false afterward, but this causes a race condition of sorts wherein characters typed by the user can be swallowed and get lost if they occur during the BindingContext switch, this problem doesn't occur often but still more frequently than I'd like.)

@FoggyFinder
Copy link
Collaborator

FoggyFinder commented Nov 8, 2017

"Some general things I'm unsure about:"
@cmeeren That is nice - I think it's better to split the general question to many small questions (like you have done) and ask in the F# Slack (I know you already joined) or in the SO (there even special tag there) or maybe just create a new issue.

"that means every character typed into a text field (based on Entry.TextChanged) goes through the entire redux loop"
I'm not familiar with redux concept - but maybe you can create separate component?(it's just a supposition, anyway I'd wait for an answer @ReedCopsey )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants