Skip to content

Instantly share code, notes, and snippets.

@baetheus
Created January 24, 2019 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baetheus/3f0e6de36bfee7a353c8f402a56062c5 to your computer and use it in GitHub Desktop.
Save baetheus/3f0e6de36bfee7a353c8f402a56062c5 to your computer and use it in GitHub Desktop.
Potential Input State Interfaces
export interface InputState<ValueType, MaskType> {
value: ValueType;
mask: MaskType; // TODO Decide on masking implementation
touched: boolean;
invalid: boolean;
focused: boolean;
disabled: boolean;
}
export enum InputEvents {
INIT,
BLUR,
CHANGE,
FOCUS,
// TODO Consider other input events
}
export interface InputAction {
type: InputEvents;
}
export interface InputStateReducer<ValueType, MaskType = ValueType> {
(state: InputState<ValueType, MaskType>, action: InputAction): InputState<ValueType, MaskType>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment