Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do Fluent Bindings handle two-way data binding compared to Swiss/Tibet bindings


How do Fluent Bindings handle two-way data binding compared to Swiss/Tibet bindings


Fluent bindings and Swiss/Tibet bindings are both part of the MvvmCross framework, which is used for cross-platform development. While both methods facilitate data binding, they differ in syntax and usage, particularly in how they handle two-way data binding.

Fluent Bindings

Fluent bindings in MvvmCross provide a more modern and flexible way to bind data between the View and ViewModel. They allow for a fluent syntax that is easier to read and write, making it simpler for developers to manage complex bindings. In the context of two-way data binding, fluent bindings enable seamless interaction between the View and ViewModel by automatically updating both when either side changes. This is particularly useful for editing forms where real-time synchronization is crucial.

Fluent bindings support value converters, which are essential for two-way data binding when the data types between the View and ViewModel differ. These converters implement both `Convert` and `ConvertBack` methods to handle data transformations in both directions[7].

Swiss/Tibet Bindings

Swiss and Tibet bindings are older syntaxes used in MvvmCross for data binding. They also support two-way data binding but with a different syntax. The Swiss syntax, for example, uses a simple format where the target property in the View is connected to a source path in the ViewModel. While it supports two-way binding, it might not be as flexible or readable as fluent bindings for complex scenarios.

Swiss bindings require specifying the binding mode explicitly if needed, which can include one-way, two-way, or one-time bindings. However, they might not offer the same level of flexibility with value converters as fluent bindings do.

Comparison

- Syntax and Readability: Fluent bindings are generally more readable and easier to manage, especially in complex scenarios. Swiss/Tibet bindings have a simpler syntax but might not be as flexible.

- Flexibility with Value Converters: Fluent bindings are more flexible when dealing with value converters, which are crucial for two-way data binding when data types differ between the View and ViewModel.

- Usage: Both methods support two-way data binding, but fluent bindings are more commonly used in modern applications due to their readability and flexibility.

In summary, while both fluent and Swiss/Tibet bindings support two-way data binding, fluent bindings offer a more modern, flexible, and readable approach, making them preferable for complex applications.

Citations:
[1] https://www.reddit.com/r/javascript/comments/v993r4/askjs_why_is_oneway_binding_better_than_twoway/
[2] https://medium.datadriveninvestor.com/implementing-two-way-data-binding-without-using-any-framework-703963d00a94
[3] https://www.bennadel.com/blog/3538-on-the-irrational-demonization-of-two-way-data-binding-in-angular.htm
[4] https://www.mvvmcross.com/documentation/fundamentals/data-binding
[5] https://www.telerik.com/blogs/angular-basics-data-binding-part-8-two-way-data-binding
[6] https://handsontable.com/blog/understanding-data-binding-in-react
[7] https://stackoverflow.com/questions/19712103/fluent-binding-and-conversions
[8] https://www.telerik.com/blogs/blazor-basics-data-binding