Using them in ionic, ngrx/store
Here at [arraydigital] we’re using the ionic framework to create some of our mobile apps. I spent some time recently adding ngrx/store to one of our ionic projects and it gave me my first opportunity to see union types in the wild.
A union type is one of the advanced types in TypeScript. It describes a value that can be one of several types. So number | string
is a type that can be either a number
or a string
. It is important to remember that a union type value will have only the members that are in common with the rest of the types in the union.
My first meeting with union types was using ngrx/store actions and reducers. Here are some simple actions from one of our ngrx/store applications. In the last line of the module: `export type Actions = LoadActio