Page MenuHomePhabricator

[MVVM] Model Insertion Features
Open, TODOPublic

Description

current Model interface only support Add() and there are no way to insert data in specific index.
we need more insertion ways in basic model interface.

  • Append : Insert model child after last child of model index. same as add
  • Prepend : Insert model child before the first child of model index.
  • Insert_At / Before / After : Insert model child before / after given index.
SanghyeonLee triaged this task as TODO priority.
SanghyeonLee added a subscriber: larryolj.

We're in agreement here. Need to add that to model and implement it in all models.

What do you think Eo model should do, since append, prepend and insert_at/before/after can't guarantee the ordering? Should we return an error or insert it in any order?

SanghyeonLee added a comment.EditedOct 24 2018, 10:03 PM

I can't understand the issue cases. which case may not guarantee the ordering?
I think if we cannot guarantee the order that we requested,
we should let the user know the failure of inserting by returning errors and do nothing further.

cedric added a subscriber: cedric.Nov 16 2018, 11:11 AM

I agree with @SanghyeonLee no silent work around solution for users. This create trouble. What is the status of this task ?

@felipealmeida ping, any update on this task?

zmike moved this task from Backlog to Felipe on the efl: mvvm board.
cedric moved this task from Felipe to Backlog on the efl: mvvm board.Jan 24 2020, 4:05 PM

This will be necessary to provide an Efl.SortedModel.

Ideally we would want the ability to insert multiple items, but that seems only possible if Model are provided and not index (As index change every time an object is inserted).

To have a Model you must traversal the whole list

Not necessarily, it depends on the internal of the code that is doing the insertion. Very often we do have Model temporary in memory that would be near where we insert. This is especially true if we are doing sorted insertion, as this require to compare models all the way to the point where we want to insert them.

I mean the user code, not the insert operation.

It really depends :-) For the moment, we do not have much example of Model. Efl.Io shows that in the same code, their is place for batch insertion and solo insertion. Not sure how our code base is going to look once we have some network Model and so on.

I am also not saying this is mandatory, but would be good to take this into account.

Can't we have a index + Iterator insert operation that inserts a range at position defined by index?

Basically that would be a batch insert at one position. This is doable, but I doubt it would be very useful.

Which usage do you see adding multiple elements in multiple places? I can't think of anything off the top of my head.

So during the initial stage of Efl.Io.Model, it does start by listing all the files in a directory. This could then be batch notified to a composite Efl.SortedModel that would then sort them out and insert them relatively to each other and to the content of the SortedModel.

Now, if we do have a user doing the same kind of thing with a database or something that is also asynchronous and does batching. As we do not provide any Model for handling Network queries or Database queries, I would assume that the simplest things someone would use to implement this, would be to use the Efl.GenericModel and add ChildModel to them. If he is using an Efl.SortedModel, then to make things not to bad, having batched add would be neat.

Arguably reading my own scenario, I don't even think we really need to even provide any alternative insert if writing your own model is easy enough. Also we need a way to "commit" change when we are doing an addition as the model should not be propagated until it is properly ready to be evaluated by everything in the pipeline. So now, I am confused with myself :-D