StorIO observeChangesInTable, can i get updated rows/items with it?

147 Views Asked by At

StorIOSQLite has interesting method observeChangesInTable(). And When I saw it I thought that it would observe changes in given table and return list of updated items.

But it just returns updated table name. Why would I need an updated table name? I can just subscribe to hole table to be notified about an update

storIoSqLite.get()
            .listOfObjects(Item.class)
            .withQuery(
                    Query.builder()
                            .table(ItemTable.NAME)
                            .build()
            )
            .prepare()
            .asRxObservable()

Please explain what is the point of observeChangesInTable() method. And what is the best solution for my problem.

1

There are 1 best solutions below

5
On BEST ANSWER

With your approach you're actually doing a query to the db and only then reacting to the change.

With StorIOSQLite.observeChangesInTable() you can react on changes in the table without doing any queries to the db. This is much much cheaper and should be used in situations when you need to do a debounce() or window(), filter() etc and only then make actual query to the db.

Hope that helps!