Skip to content

Instantly share code, notes, and snippets.

@kurtmilam
Last active May 29, 2017 10:08
Show Gist options
  • Save kurtmilam/91c2eb7818765c63126c001ac45c0dc8 to your computer and use it in GitHub Desktop.
Save kurtmilam/91c2eb7818765c63126c001ac45c0dc8 to your computer and use it in GitHub Desktop.
calmm-js crud form component experiment
const makeQuery =
U.pipe( U.template
, U.flatMapLatest( L.get( [ 0, U.pipe( Req.withParams( url ), Req.getJSON ) ] ) )
)
const getItem =
U.view( [ 'response', 'body', L.define( {} ) ] )
export const Edit =
U.withContext(
( { id } ) => {
const state = U.variable()
const item = U.view( [ 'item', L.valueOr( {} ) ], state )
const jsonFieldL = [ 'a', L.json(), L.defaults( {} ) ]
return (
<div className="crud-form">
<LabeledTextInput lens={ [ jsonFieldL, 'b' ] }
item={ item }/>
{ U.set( item, getItem( makeQuery( [ { id } ] ) ) ) }
</div>
)
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment