AaronErhardt / AaronErhardt.github.io

My personal blog

Home Page:https://aaronerhardt.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Give overview of available factories

tronta opened this issue · comments

in this chapter https://aaronerhardt.github.io/relm4-book/book/factory.html
I would find it valuable if you could give an overview of other exiting factories than FactoryVec and their properties (link to their documentation)

That definitely makes sense but so far there is only FactoryVec and FactoryVecDeque which are both covered by the book. But an overview is nice, anyway.

I've added this section to the docs: https://aaronerhardt.github.io/docs/relm4/relm4/factory/collections/index.html#which-factory-type-to-use

Where would you mention this in the book or is it enough to have it in the docs?

I'm a table person, but with only two it might be an overkill 😀
When I wrote this, I was not aware that there are just those two. The book keeps it somehow open, if those are sufficient or if others are planned. Maybe one sentence could help: currently there are two types available. Additional ones might come in future.
If you know what I mean...
I'm just loud thinking.
But if you want, you can also close it.

Maybe it is also worth mentioning, what happens if one stores data in non Factory type, eg Vec, data types. How would one modify/display this data?
Should one always use eg FactoryVec instead of Vec? How does it play together with other libraries like Serde?
Or should one copy/sync data between those structures? If yes, what is the best way?

You can use anything you want. Factories are just for convenience. Using a Vec has the problem that you need to generate you're UI somehow and a Vec doesn't provide any information for efficient UI updates by default. I should probably add methods to access or initialize the internal data (which is unsurprisingly stored in a Vec or VecDeque) so that you can use Serde with factories.

Or did you have some specific problem or use-case in mind?

Yes, I guess I mean this. For learning relm, I'm trying to build a little program. In this program I want to edit/display data (strings) which is stored in a hierarchical Vecs/little bit complexer data structure. And on different levels of the UI I want to display/edit a subset of it.
So in order to provide the data to the UI, I probably would need to provide it in an efficient way to be displayed.

Not sure if this would work, but would it be possible to split up data in two parts, one for storing/accessing the data in a standard way, and an other part for tracking changes (which could be also triggered manually), and then to handover it to the UI (loud thinking)?

Yes, of course. I think factories are probably only really useful for linear data (although in theory you could even have nested factories). If you need something more complex you will need to implement your own mechanism to track changes.