threepointone / rakt

fast websites, by default
291 stars 12 forks source link

get/post/put/del #17

Open threepointone opened 7 years ago

threepointone commented 7 years ago

much like @initial, but functions corresponding to each will be fed into the component as props, and the component will be expected to call them. example -

@post(async ({ username, password }) => {
  return await require('./auth').validate(username, password)
})
export class Login extends Component{
  render(){
    let { action, post, posting, posted, response, error, next } = this.props
    return posted ? <form onSubmit={post} action={action}>
      <input name='username'/>
      <input name='password'/>
    </form> :
    posting ? <span>checking ...</span> : 
    response ? <Redirect to={next}/> : 
    <div>
      login failed! {error}
    </div>
  }
}