Aff refactor and Suspense experiments #22
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I also normalized the examples a bit so it's easier to add new ones. You can now copy/paste an existing example's folder, rename the folder, and edit the
src/Example.purs
file.I'd also like to clean up the Aff and Suspense examples a bit. They're just a bit hard to read atm.
useAff refactor
Previously
useAff
returnedMaybe (Either Error a)
. It no longer enforces that explicit error capturing, returning onlyMaybe a
. This means you now have three options:useAff deps go
becomesuseAff deps (try go)
useAff deps go
and remove the code handling the innerEither
This may sound crazy at first, but error boundaries aren't for normal application logic. If your Aff has known failure cases which you need to code for, you definitely want
try
, or your own data type. But in many cases, an Aff failure is just a network error, or a bug, or a hacker/typo/url-copy-paste-error. These unusual error paths don't fit in your UI components, and often just get logged to the console. Error boundaries help you capture, log, notify, etc, all in one place, cleaning up your UI components in the process (React's Suspense api is this same concept but for loading states, more below).general api cleanup
Little things I've been meaning to do in
React.Basic.Hooks
for a while, as well as a fewuseEffect
helpers inspired by halogen-hooks. The largest impact change is renamingcomponent
toreactComponent
and exposing a newcomponent
which instead returnsEffect (props -> JSX)
, also aliased asComponent props
. When you use this function, you are no longer constrained to using a Record, and even if you do use a Record there are no limitations on its fields. This simplifies components a bit for most PureScript-only applications.suspense experiments
Added a few tools for experimenting with React's suspense api and concurrent mode: