10월, 2021의 게시물 표시

promise의 이해1

promise의 이해1 func1 () . then ( func2 ) . then ( func3 ) . then ( func4 ) . then ( func5 ) . then ( func6 ) . then ( func7 ); function func1 (){ return new Promise (( resolve , reject ) => { console . log ( 'func1실행' ); setTimeout ( resolve , 2000 ) }) } function func2 (){ return new Promise (( resolve , reject ) => { console . log ( 'func2실행' ); setTimeout ( resolve , 2000 ) }) } function func3 (){ return new Promise (( resolve , reject ) => { console . log ( 'func3실행' ); setTimeout ( resolve , 2000 ) }) } function func4 (){ console . log ( 'func4실행' ); } function func5 (){ console . log ( 'func5실행' ); } function func6 (){ return new Promise (( resolve , reject ) => { console . log ( 'func6-1실행' ); //setTimeout(resolve, 2000); func6_1...

promise의 이해2

promise의 이해2 func1 ( 10 ). then (( res ) => { func2 ( res ). then (( res ) => { func3 ( res ) }) }) ; function func1 ( val_in ){ return new Promise (( resolve , reject ) => { console . log ( 'func1실행: val_in=' + val_in ); setTimeout (() => { funcProcessing ( 'func1' , val_in ). then (( res ) => { resolve ( res ); }) }, 2000 ); }) } function func2 ( val_in ){ return new Promise (( resolve , reject ) => { console . log ( 'func2실행: val_in=' + val_in ); setTimeout (() => { funcProcessing ( 'func2' , val_in ). then (( res ) => { resolve ( res ); }) }, 5000 ); }) } function func3 ( val_in ){ return new Promise (( resolve , reject ) => { console . log ( 'func3실행: val_in=...