Comments (2)
Thanks for the report!
I managed to reproduce with the example given 👍
What's happening in your case is that Fabulous expects your items
to be a stable reference value (aka mutable list) instead of a non-mutable one (like F# list
type where a new list instance is created with each mutation).
If the reference changes, Fabulous will consider the whole list needs to be reloaded and will lose the DataTemplates that were created previously -- causing the crash on Android after reaching the limit of .NET MAUI.
A workaround would be to change the Model
type:
type Model = { Items: ObservableCollection<Item> }
Note: I'm using ObservableCollection instead of any System.Collections.IList type, because .NET MAUI expects the collection to raise events when adding/removing items which ObservableCollection do
Then, you can still add and remove items like usual.
let init () =
let items = ObservableCollection<Item>()
items.Add(Item.create())
{ Items = items }, Cmd.none
let update msg model =
match msg with
| Add ->
model.Items.Add(Item.create())
model, Cmd.none
| RemoveLast ->
if model.Items.Count > 0 then
model.Items.RemoveAt(model.Items.Count - 1)
model, Cmd.none
This approach will work, though it has some drawbacks because of the mutated collection (especially if you want clean separation between states).
Virtualized collection widgets like ListView are very tricky to work with in Fabulous, and can easily crash.
I'm not really satisfied with our implementation.
from fabulous.mauicontrols.
Thanks you for the quick reply :)
This workaround is fine for my needs.
May I close this issue ?
It could be interesting to keep it opened though, as someone else might encounter this issue (since using F# list is instinctive): keeping it opened makes the workaround visible.
from fabulous.mauicontrols.
Related Issues (12)
- App seems to be running in phone compatibility mode on iPad
- Broken doc link on main page HOT 2
- GroupedCollectionView mutiple selection resets other sections
- Screen flicker in sample app HOT 1
- TicTacToe sample crashes during startup for the Windows target
- Get Started with Fabulous.MauiControls link to 404 HOT 1
- Incorrect command in the docs? HOT 1
- Issue getting started from the docs HOT 2
- NavigationView raises out array out bounds exception when navigatedBack on iOS while diffing widgets HOT 2
- WebView does not render content HOT 5
- Setting a WebViewer's MixedContentMode to AlwaysAllow on Android does not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabulous.mauicontrols.