WatermelonDB v0.16 Release Notes
Release Date: 2020-03-06 // about 4 years ago-
โ ๏ธ Breaking
experimentalUseIncrementalIndexedDB
has been renamed touseIncrementalIndexedDB
Low breakage risk
- [adapters] Adapter API has changed from returning Promise to taking callbacks as the last argument. This won't affect you unless you call on adapter methods directly.
database.adapter
returns a newDatabaseAdapterCompat
which has the same shape as old adapter API. You can usedatabase.adapter.underlyingAdapter
to get backSQLiteAdapter
/LokiJSAdapter
- ๐ [Collection]
Collection.fetchQuery
andCollection.fetchCount
are removed. Please useQuery.fetch()
andQuery.fetchCount()
.
๐ New features
- ๐ [SQLiteAdapter] [iOS] Add new
synchronous
option to adapter:new SQLiteAdapter({ ..., synchronous: true })
. When enabled, database operations will block JavaScript thread. Adapter actions will resolve in the next microtask, which simplifies building flicker-free interfaces. Adapter will fall back to async operation when synchronous adapter is not available (e.g. when doing remote debugging) - [LokiJS] Added new
onQuotaExceededError?: (error: Error) => void
option toLokiJSAdapter
constructor. This is called when underlying IndexedDB encountered a quota exceeded error (ran out of allotted disk space for app) This means that app can't save more data or that it will fall back to using in-memory database only Note that this only works whenuseWebWorker: false
๐ Changes
- ๐ [Performance] Watermelon internals have been rewritten not to rely on Promises and allow some fetch/observe calls to resolve synchronously. Do not rely on this -- external API is still based on Rx and Promises and may resolve either asynchronously or synchronously depending on capabilities. This is meant as a internal performance optimization only for the time being.
- ๐ [LokiJS] [Performance] Improved worker queue implementation for performance
- ๐ [observation] Refactored observer implementations for performance
๐ Fixes
- ๐ Fixed a possible cause for "Record ID xxx#yyy was sent over the bridge, but it's not cached" error
- ๐ [LokiJS] Fixed an issue preventing database from saving when using
experimentalUseIncrementalIndexedDB
- ๐ Fixed a potential issue when using
database.unsafeResetDatabase()
- ๐ [iOS] Fixed issue with clearing database under experimental synchronous mode
๐ New features (Experimental)
- [Model] Added experimental
model.experimentalSubscribe((isDeleted) => { ... })
method as a vanilla JS alternative to Rx basedmodel.observe()
. Unlike the latter, it does not notify the subscriber immediately upon subscription. - [Collection] Added internal
collection.experimentalSubscribe((changeSet) => { ... })
method as a vanilla JS alternative to Rx basedcollection.changes
(you probably shouldn't be using this API anyway) - ๐ฆ [Database] Added experimental
database.experimentalSubscribe(['table1', 'table2'], () => { ... })
method as a vanilla JS alternative to Rx-baseddatabase.withChangesForTables()
. Unlike the latter,experimentalSubscribe
notifies the subscriber only once after a batch that makes a change in multiple collections subscribed to. It also doesn't notify the subscriber immediately upon subscription, and doesn't send details about the changes, only a signal. - โ Added
experimentalDisableObserveCountThrottling()
to@nozbe/watermelondb/observation/observeCount
that globally disables count observation throttling. We think that throttling on WatermelonDB level is not a good feature and will be removed in a future release - and will be better implemented on app level if necessary - [Query] Added experimental
query.experimentalSubscribe(records => { ... })
,query.experimentalSubscribeWithColumns(['col1', 'col2'], records => { ... })
, andquery.experimentalSubscribeToCount(count => { ... })
methods