urgent/thisbounty.com-events

io-ts

urgent opened this issue · 14 comments

Skipped. Worried about bundle size.

Function composition for effects, for testing.

#3.2

fp-ts with effects in separate file.

React Profiler displayName property

#3.4

Otherwise shows component name as Anonymous

setState(() => {})

#3.5

function version for extra time in useEffect. Don't need if you know what you are doing. If working with useEffect, check dependency list second parameter, [], pass anything that will change in an array.

Event emitter and reconciliation/render strategy

#3.6

If shared props are needed, move to parent component. Create a parent component if needed just for props.

Efficient render for events

io-ts Runtime decode

#3.7

Runtime and compile time type checks. Use io-ts please. It's awesome.

https://www.tooploox.com/blog/bridging-static-and-runtime-types-with-io-ts

Don't Be Afraid to Write Types

#3.8

A single name is a lot clearer than multiple curries of different types.

Folds

#3.9

folding either, using separate handles for left and write. Return a union type. Detect, and run effects.

Task instead of io

#3.10

No need to nest an io in a task. Task does all that for you anyways. If need more, look at flutures.

Reader

#3.11

Instead of passing params, call for a reader once all folds are done and effects lined up.

Run effects on dependency input.

effects, like setState would need to be curried and pass to every fold.

setting the same state does not result in a render.

state in useEffect deps list

#3.12

If useEffect needs existing state, put state in useEffect's deps list, the second parameter where you usually put [].

This one will drive you crazy.

Avoid unit testing function composition

#3.13

Despite being first class functions, testing for equality between functions is difficult. Serialization exists, but that defeats the idea of unit tests. Best to pass similar parameters and look at output so unit is more durable to future versions.

Throwing exception inside a jest async.

#3.14

Best to test if function is returned. Difficult to do in jest as jest halts on throw unless wrapped in anonymous functions. async makes it difficult. Better strategy is to return either the effectfull function or error only. Test the effect in a different unit. Only check if function is callable, expect.any(Function)

except.any instead of type of

#3.15

Looks better.