import { BindState , DirectiveParameters } from "../types" ; function promiseDirective ( { element , expression , evaluate , setState , } ) { const { state } = evaluate ( expression ) ; Promise . all ( Object . values ( state ) ) . then ( ( values ) => { const newState = { } ; Object . keys ( state ) . forEach ( ( key , i ) => { newState [ key ] = values [ i ] ; } ) ; setState ( newState , { element } ) ; } ) . catch ( ( error ) => { setState ( { error } , { element } ) ; } ) ; } promiseDirective . skipEvaluation = true ; export default promiseDirective ;