Please note that my breakdown is my own mental model, it might not be correct for Sodium!
I don't use the Typescript version, but at first sight it is missing a public static Transaction.post
method that might be used for delaying an action.
I'm not sure why this code wasn't added, but looking at the Java version, it seems easy to cook your own version:
public static void post(final Runnable action) {
Transaction.run(new Handler<Transaction>() {
public void run(Transaction trans) {
// -1 will mean it runs before anything split/deferred, and will run
// outside a transaction context.
trans.post_(-1, new Handler<Transaction>() {
public void run(Transaction trans) {
action.run();
}
});
}
});
}
Since the Typescript Transaction
class does have run
and post(childIx: number, action: () => void): void
methods, the Java code above would be easy to transfer.
Otherwise I would use setImmediate
or ASAP
in Typescript, see the NPM registry