react, redux, and archetype

14
Casting and Validating State With Archetype Valeri Karpov Booster Fuels @code_barbarian github.com/vkarpov15

Upload: valeri-karpov

Post on 28-Jan-2018

94 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: React, Redux, and Archetype

Casting and Validating State With Archetype

Valeri KarpovBooster Fuels

@code_barbarian

github.com/vkarpov15

Page 2: React, Redux, and Archetype

About Me

Page 3: React, Redux, and Archetype

React Credentials

Page 4: React, Redux, and Archetype

What is Archetype?

Cast a given obj’s properties to the correct types

Page 5: React, Redux, and Archetype

So It’s Joi, JSONSchema, PropTypes, Flow?

● Easy custom types & nested (vs Joi, JSONSchema)

● Casting + validation in middleware vs PropTypes

● Runtime, not compile time vs Flow (buggy APIs)

Page 6: React, Redux, and Archetype

Core Principles

● Composable: can nest and transform types

● Inspectable: introspect deeply nested paths

● Extendable: any class is a valid custom type

Page 7: React, Redux, and Archetype

Data for Calendar App in React

Page 8: React, Redux, and Archetype

Rendering comes with Assumptions

Page 9: React, Redux, and Archetype

And With Bad Data?

Page 10: React, Redux, and Archetype

Use Archetype to Consolidate LogicUsing Action Creators

Page 11: React, Redux, and Archetype

Know Your Assumptions are Correct

Page 12: React, Redux, and Archetype

And No More Walls of If Statements

Page 13: React, Redux, and Archetype

More Info on Archetype

● Gists of the week available on

npmjs.com/package/archetype

● Casting and Validating GeoJSON With Archetype

on thecodebarbarian.com

Page 14: React, Redux, and Archetype

Thanks!

Code samples: /vkarpov15/zcal-client-example