Skip to main content
cngx-src documentation

resolveAsyncView

Functioncommon/data/async-state

projects/common/data/async-state/resolve-view.ts

Description#

Pure function that resolves which view to show based on async state.

Encodes the state machine as a lookup table — no branching:

status firstLoad empty view
idle true * none
loading true * skeleton
refreshing true * skeleton
pending true * skeleton
error true * error
success * true empty
error false * content+error
(all other) * * content

Signature#

resolveAsyncView(status: AsyncStatus, firstLoad: boolean, empty: boolean)

Parameters#

@paramstatusAsyncStatus
@paramfirstLoadboolean
@paramemptyboolean

Returns#

AsyncView