royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Ent <p...@adobe.com.INVALID>
Subject Re: List, MDL Table - How to remove all content
Date Tue, 05 Dec 2017 16:15:56 GMT
If you remove everything from the ArrayList, the ArrayList dispatches
ITEM_REMOVED for each item (if you have 1000 items you will get 1000
events). ArrayList should probably not do that and instead, dispatch a
single COLLECTION_CHANGED event once completed.

But the RemoveItemBead will in fact, handle each ITEM_REMOVED event and
eventually clear out the list. To be more efficient, another bead should
be made since DataItemRendererFactoryForArrayList does not listen to
COLLECTION_CHANGED (perhaps it should or perhaps we need a new PAYG
enhanced version of that).

I have also been toying with just updating
DynamicItemsRenderFactoryForArrayList to make it handle all the cases and
forget the individual beads. You can pay little by using the
DataItemRendererFactoryForArrayList bead if you just want to display a
static list or pay it all and use DynamicItemsRendererFactoryForArrayList
even though you may only be inserting and never removing items.

—peter



On 12/5/17, 10:17 AM, "Piotr Zarzycki" <piotrzarzycki21@gmail.com> wrote:

>However those two beads are for remove single items? What if I remove
>everything from the ArrayList?
>
>On Tue, Dec 5, 2017, 16:16 Piotr Zarzycki <piotrzarzycki21@gmail.com>
>wrote:
>
>> Those two beads will handle remove/add, so will I be able to use it for
>> list?
>>
>> It look like all your upcoming changes is something which I need for.
>>
>> I'm look forward to your commit!
>>
>> Thanks, Piotr
>>
>> On Tue, Dec 5, 2017, 16:03 Peter Ent <pent@adobe.com.invalid> wrote:
>>
>>> I am working on an AddItemBead and RemoveItemBead. These beads assume
>>>the
>>> dataProvider in the model are ArrayList since that collection
>>>dispatches
>>> CollectionEvents with itemAdded and itemRemoved events. So these beads
>>> will either add an item to the DataGroup or remove one. Then they will
>>> adjust the model's selectedItem and selectedIndex accordingly.
>>>
>>> These will be beads of the DataItemRendererFactoryForArrayList and not
>>> beads on the List itself. I'm having to change
>>> DataItemRendererFactoryForArrayList to make things more public since it
>>> isn't trivial to add or remove an itemRenderer.
>>>
>>> —peter
>>>
>>> On 12/5/17, 9:51 AM, "Piotr Zarzycki" <piotrzarzycki21@gmail.com>
>>>wrote:
>>>
>>> >Hi Peter,
>>> >
>>> >I see that and there is question whether I can put that code as a
>>> separate
>>> >bead to our repo and whether you are not going to do this?
>>> >You have started other thread about Tree Grid and beads mentioned by
>>>you
>>> >seems to be the answer. Let me know before I create something.
>>> >
>>> >Thanks, Piotr
>>> >
>>> >On Tue, Dec 5, 2017, 15:43 Peter Ent <pent@adobe.com.invalid> wrote:
>>> >
>>> >> I think some of this changes when you are running in the browser.
>>>Does
>>> >>our
>>> >> framework code really need to know if an item is visible or not to
>>> >>remove
>>> >> it? You want it gone from the DOM so you need to remove it and the
>>> >>browser
>>> >> takes care of the visuals. Depending on the CSS for that container,
>>> >>things
>>> >> would probably just sort themselves out - no need to fool with
>>> >>scrollbars
>>> >> either as they are the responsibility of the browser. On the browser
>>> >> platform, adding a remove function would not, I think, be as costly
>>>as
>>> >>it
>>> >> would on the Flash platform.
>>> >>
>>> >> Now the selectedItem and selectedIndex are, of course, Royale
>>>things so
>>> >> that would need to be considered. But that's the same as for adding
>>>or
>>> >> inserting an item into a list. Again, the browser should take care
>>>of
>>> >>the
>>> >> visuals once the item is added to the DOM. If the item has been
>>>tagged
>>> >> properly for CSS, you wouldn't even need to trigger the Royale
>>>layout.
>>> >>
>>> >> As a side note, the reason the Group does not have a default layout
>>>is
>>> >>to
>>> >> allow you to make a DIV (the Group), put stuff into it, and style
>>>it so
>>> >> that the "layout" is handled in CSS. This way added, removing,
>>>changing
>>> >>is
>>> >> left up the browser with no need for Royale code support since the
>>> >>browser
>>> >> has all the code already and your Royale payload can be smaller. You
>>> >>only
>>> >> need to "pay" if you want a layout that cannot be accomplished with
>>> CSS.
>>> >>
>>> >> Supporting virtualized list is a completely different matter. HTML
>>> >>doesn't
>>> >> support that and then what Alex says really comes into play there.
>>> >>
>>> >> Back the question about removing all the rows. The DataGroup has a
>>> >> function to remove all of the itemRenderers. You need to trigger
>>>that
>>> >> somehow - either in your own code or perhaps a bead. Then clean up
>>>the
>>> >> selectedItem/selectedIndex in the model.
>>> >>
>>> >> ‹peter
>>> >>
>>> >> On 12/5/17, 12:03 AM, "Alex Harui" <aharui@adobe.com.INVALID>
wrote:
>>> >>
>>> >> >In general, removing stuff should be PAYG.  Not every app needs
to
>>> >>remove
>>> >> >things, and removal is often way more expensive than adding.
>>> >> >
>>> >> >For example, when an item is added to a sophisticated list, the
>>> various
>>> >> >beads have to do these things:
>>> >> >1) figure out if the item is on screen and a new renderer needs
to
>>>be
>>> >> >added.
>>> >> >2) figure out if the item was added before the selectedIndex so
the
>>> >> >selectedIndex needs to be updated
>>> >> >3) update the scrollbar (if any).
>>> >> >
>>> >> >When removing, the various beads have more to do:
>>> >> >1) figure out if the item is on screen and its renderer needs to
be
>>> >> >removed.
>>> >> >2) figure out if the renderer removed is on the last visible page
>>>of
>>> >>the
>>> >> >list and scrollbars are up and the item that will take up the
>>>removed
>>> >> >renderer needs to come from a lower index in the data provider
>>> >> >3) figure out if the item was added before the selectedIndex so
the
>>> >> >selectedIndex needs to be updated
>>> >> >4) figure out if the item removed was the selectedIndex and thus
>>> decide
>>> >> >what to do about selectedIndex and selectedItem
>>> >> >5) update the scrollbar (if any).
>>> >> >
>>> >> >HTH,
>>> >> >-Alex
>>> >> >
>>> >> >
>>> >> >On 12/4/17, 5:08 PM, "Peter Ent" <pent@adobe.com.INVALID>
wrote:
>>> >> >
>>> >> >>I need to think about this for a bit because I¹m fiddling with
>>>this
>>> >>bit
>>> >> >>of code in List. I¹ll get back to you in my tomorrow.
>>> >> >>
>>> >> >>Peter
>>> >> >>
>>> >> >>
>>> >> >>> On Dec 4, 2017, at 4:53 PM, Piotr Zarzycki
>>> >><piotrzarzycki21@gmail.com>
>>> >> >>>wrote:
>>> >> >>> Hi Guys,
>>> >> >>>
>>> >> >>> I have faced an issue where solution seems to be not so
easy. I
>>> have
>>> >> >>>MDL
>>> >> >>> Table (issue affects also List) with some rows.
>>> >> >>>
>>> >> >>> If I simply assign to dataProvider = null it doesn't remove
all
>>> >> >>>content. It
>>> >> >>> is because in our DataItemRendererFactoryForArrayData and
other
>>> >>type of
>>> >> >>> that class we have in listeners of  "dataProviderChanged"
this
>>>code
>>> >> >>>[1].
>>> >> >>> Basically if we assign null to dataProvider we are not
cleaning
>>>up
>>> >>item
>>> >> >>> renderers, but should we ?
>>> >> >>>
>>> >> >>> Maybe there should be separate bead which allow to do such
>>> >>operations ?
>>> >> >>>
>>> >> >>> Thoughts ?
>>> >> >>>
>>> >> >>> [1]
>>> >>
>>> >>>>>*
>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpast
>>> >>>>>e
>>> >> .
>>> >> >>>a
>>> >> >>>pache.org%2F6qVy&data=02%7C01%7Cpent%40adobe.com
>>> >> %7C05ca01d43a8448485bd50
>>> >> >>>8
>>> >>
>>>
>>> 
>>>>>>>>d53b617760%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C63648021216
>>>>>>>>449
>>> >>>>>91
>>> >> >>>9
>>> >> >>>9&sdata=6mmrQ1g5CRuRmRyRpSLNil3LUn93jAKTJVI6RHSocL8%3D&reserved=0
>>> >>
>>> >>>>><
>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpast
>>> >>>>>e
>>> >> .
>>> >> >>>a
>>> >> >>>pache.org%2F6qVy&data=02%7C01%7Cpent%40adobe.com
>>> >> %7C05ca01d43a8448485bd50
>>> >> >>>8
>>> >>
>>>
>>> 
>>>>>>>>d53b617760%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C63648021216
>>>>>>>>449
>>> >>>>>91
>>> >> >>>9
>>> >> 
>>>>>>9&sdata=6mmrQ1g5CRuRmRyRpSLNil3LUn93jAKTJVI6RHSocL8%3D&reserved=0>*
>>> >> >>>
>>> >> >>> Thanks,
>>> >> >>> --
>>> >> >>>
>>> >> >>> Piotr Zarzycki
>>> >> >>>
>>> >> >>> Patreon:
>>> >> >>>*
>>> >>
>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.pa
>>> >> >>>t
>>> >> >>>reon.com%2Fpiotrzarzycki&data=02%7C01%7Cpent%40adobe.com
>>> >> %7C05ca01d43a844
>>> >> >>>8
>>> >>
>>>
>>> 
>>>>>>>>485bd508d53b617760%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636
>>>>>>>>480
>>> >>>>>21
>>> >> >>>2
>>> >>
>>>
>>> 
>>>>>>>>164499199&sdata=Lh5NSyP1MPIG6h5X4eG9RW3MWcQMiMBDevLzt8WoPS4%3D&rese
>>>>>>>>rve
>>> >>>>>d=
>>> >> >>>0
>>> >> >>>
>>> >> >>><
>>> >>
>>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.pa
>>> >> >>>t
>>> >> >>>reon.com%2Fpiotrzarzycki&data=02%7C01%7Cpent%40adobe.com
>>> >> %7C05ca01d43a844
>>> >> >>>8
>>> >>
>>>
>>> 
>>>>>>>>485bd508d53b617760%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636
>>>>>>>>480
>>> >>>>>21
>>> >> >>>2
>>> >>
>>>
>>> 
>>>>>>>>164499199&sdata=Lh5NSyP1MPIG6h5X4eG9RW3MWcQMiMBDevLzt8WoPS4%3D&rese
>>>>>>>>rve
>>> >>>>>d=
>>> >> >>>0
>>> >> >>>>*
>>> >> >
>>> >>
>>> >>
>>>
>>>

Mime
View raw message