Closed carocad closed 6 years ago
:shipit: This branch has been deployed to: https://expo.io/@carocad/hive?release-channel=transact
Download the Expo app and scan this QR code to get started!
So basically this is promise chaining.
So basically this is promise chaining.
partially yes. This is about promises that returns transaction which contain other promises.
Promise-inception if you would prefer 😅
:shipit: This branch has been deployed to: https://expo.io/@carocad/hive?release-channel=transact
Download the Expo app and scan this QR code to get started!
Previously we had to do
(run! transact! (my-custom-transaction))
to execute a series of transactions together with side-effects.This worked well for some cases, however, in the case of asynchronous function the behaviour was not clear. Since the user was the one executing the transaction (when it is available) we were forced to assume that the result of a promise was a single transaction element.
The problem arises when the result of one promise is meant to create more promises together with a transaction. There was just no way to do this before. In particular, the case that I had was that the result from
kamal directions/
endpoint returns GTFS entities which I also want to request fromkamal
(such as trip headsign or route color/type), but there was no way to do this due to the assumption above.This PR attempts to change that merging together Datascript transactions with
effect
execution and asynchronous function.From now on, all
effects
are executed first and then we update the Datascript db with the transaction.