Invoke an async thunk and convert its resolution or rejection into a ResultAsync. Synchronous throws from fn itself are also captured.
fn
const chargeCard = (order: Order) => fromAsync( () => paymentsApi.charge(order.total, order.card), (cause) => ({ code: "CHARGE_FAILED", cause }), ) Copy
const chargeCard = (order: Order) => fromAsync( () => paymentsApi.charge(order.total, order.card), (cause) => ({ code: "CHARGE_FAILED", cause }), )
Invoke an async thunk and convert its resolution or rejection into a ResultAsync. Synchronous throws from
fnitself are also captured.