Commit graph

11 commits

Author SHA1 Message Date
Bruno Windels 6d7c983e8e convert (Base)ObservableMap to typescript 2022-03-09 11:33:49 +01:00
RMidhunSuresh dea0cad252 Fix bug in FilteredMap
Caused multiple updates to be triggered.

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
2021-07-16 17:08:18 +05:30
Bruno Windels c6e2607f1f guard against updates emitted while populating during first subscription
This came up now because Timeline uses a MappedList to map PendingEvents
to PendingEventEntries. In the map function, we setup links between
entries to support local echo for relations. When opening a timeline
that has unsent relations, the initial populating of the MappedList
will try to emit an update for the target entry in remoteEntries.
This all happens while the ListView of the timeline is calling subscribe
and all collections in the chain are populating themselves based on
their sources.

This usually entails calling subscribe on the source,
and now you are subscribed, iterate over the source (as you're not
allowed to query an unsubscribed observable collection, as it might not
be populated yet, and even if it did, it wouldn't be guaranteed to be
up to date as events aren't flowing yet).

So in this concrete example, TilesCollection hadn't populated its tiles
yet and when the update to the target of the unsent relation reached
TilesCollection, the tiles array was still null and it crashed.

I thought what would be the best way to fix this and have a solid model
for observable collections to ensure they are always compatible with
each other. I considered splitting up the subscription process in two
steps where you'd first populate the source and then explicitly start
events flowing.

I didn't go with this way because it's really only updates that
make sense to be emitted during setup.
A missed update wouldn't usually bring the collections out of sync
like a missed add or remove would. It would just mean the UI isn't
updated (or any subsequent filtered collections are not updated),
but this should be fine to ignore during setup, as you can rely
on the subscribing collections down the chain picking up the update
while populating. If we ever want to support add or remove events
during setup, we would have to explicitly support them, but for now
they are correct to throw.

So for now, just ignore update events that happen during setup
where needed.
2021-05-27 10:02:05 +02:00
Bruno Windels 025320b83e fix filtered map 2021-04-27 16:15:20 +02:00
Bruno Windels 1d3a2aca0e add 'get' method to common observable map api 2021-04-21 17:23:49 +02:00
Bruno Windels b27f6a067f implement .size for all observable maps
as SortedMapList uses it, putting undefined in its list
initially when missing, creating a crash in
the TemplateView that renders it
2020-11-05 12:00:17 +01:00
Bruno Windels 84425fad5c more work on FilteredMap (not done yet though)
I ended up not using this, but at some point we'll need it,
so commit this work
2020-10-06 12:19:08 +02:00
Bruno Windels 943467cf67 actually implemented filtered map 2020-10-05 18:18:44 +02:00
Bruno Windels 00a85697ab add license header in all source files 2020-08-05 18:38:55 +02:00
Bruno Windels 001dbefbcf stop using default exports
because it becomes hard to remember where you used them and where not
2020-04-20 21:26:39 +02:00
Bruno Windels 618c4ffe20 restructure observable collections and fixes for sort, filter and map 2019-02-26 20:48:57 +01:00
Renamed from src/observable/map/operators/MapOperator.js (Browse further)