This course is no longer maintained and may be out-of-date. While it remains available for reference, its content may not reflect the latest updates, best practices, or supported features.
Handle loading/errors
As we saw in the previous step, the response data is captured using RemoteData
. The data can be in one of the following states
Loading
: Indicates whether the request is in flight. If it is inLoading
state, then the request hasn't finished. Typically this information can be used to display a loading spinner.Failure
: Indicates the request has failed. Current implementation shows a placeholder message.Success
: Indicates the request has succeeded. This information can be used to render the information.
The render function is equipped to handle the above states. It renders
Loading
: Shows a loading spinnerFailure
: Shows a custom errorSuccess
: Renders the list of todos
renderTodos : PrivateTodo -> Html MsgrenderTodos privateData =div [ class "tasks_wrapper" ] <|case privateData.todos ofRemoteData.NotAsked ->[ text "" ]RemoteData.Success todos ->[ todoListWrapper privateData.visibility todos ]RemoteData.Loading ->[ span [ class "loading_text" ][ text "Loading todos ..." ]]RemoteData.Failure err ->[ text "Error loading todos" ]
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs

