Last active
May 29, 2017 10:08
-
-
Save kurtmilam/91c2eb7818765c63126c001ac45c0dc8 to your computer and use it in GitHub Desktop.
calmm-js crud form component experiment
This file contains 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
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