Created
November 12, 2015 04:29
-
-
Save iamdustan/6856f88761e70b0f7dad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
type Auth = { | |
username: string; | |
password: string; | |
} | |
type Auth2 = { | |
username: string; | |
} | |
type AuthKeys = $Keys<Auth>; // make an enum type, with unknown key set | |
type ReduxFormOptions<T> = { | |
fields: Array<$Keys<T>>; | |
onSubmit?: (values:T, dispatch:Function) => ?Promise<?Object>; | |
}; | |
type ReduxForm<T> = (opts:ReduxFormOptions<T>) => void; | |
// can I declare the paremeterized type at consumption time? | |
// there is one reduxForm function for the app, which should | |
// be paramterized when used. | |
// something like: | |
// | |
// const AuthForm<Auth> = reduxForm(...); | |
const reduxForm:ReduxForm = (options) => {}; | |
const AuthForm = reduxForm({ | |
fields: ['username', 'password'], | |
onSubmit(values, dispatch) { | |
dispatch(authAction(values)); | |
} | |
}) | |
const AuthForm2 = reduxForm({ | |
fields: ['username', 'password'], | |
onSubmit(values:Auth2, dispatch) { | |
dispatch(authAction(values)); | |
} | |
}) | |
const authAction = (auth:Auth) => auth; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment