ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 리덕스 사가의 이펙트란?
    후론트엔드 련습/사가 2019. 1. 16. 16:32




    https://redux-saga.js.org/에서 발췌하여 

    구글 번역기를 돌리고 이상한 부분은 수정했습니다.

    즐감하세요.



    1. Beginner Tutorial에서.

    Effects are simple JavaScript objects which contain instructions to be fulfilled by the middleware. When a middleware retrieves an Effect yielded by a Saga, the Saga is paused until the Effect is fulfilled.

    이펙트는 미들웨어가 수행되는 명령을 담고있는 간단한 자바스크립트 객체입니다. 미들웨어가 Saga에 의해 yield 된 이펙트를 받을때, Saga 는 이펙트가 수행될때까지 정지합니다.


    2.2 Declarative Effects에서.

     To express the Saga logic, we yield plain JavaScript Objects from the Generator. We call those Objects Effects.

    Saga 로직을 표현하기 위해서 우리는 제너레이터로부터 온 순수 자바스크립트 객체를 yield 합니다. 이런 오브젝트들을 이펙트 라고 부릅니다.


    the Generator will yield plain Objects containing instructions, and the redux-sagamiddleware will take care of executing those instructions and giving back the result of their execution to the Generator.

    제너레이터는 명령 을 담고 있는 순수한 객체를 yield 할 것이고, redux-saga 미들웨어는 이런 명령들의 실행을 처리하고, 그 실행의 결과를 제너레이터에 돌려줄 것입니다.


    8. API Reference

    - Effect Creators

    • Each function below returns a plain JavaScript object and does not perform any execution.
    • 아래의 각 함수는 일반 JavaScript 객체를 반환할뿐 어떤 실행을 하지는 않습니다.
    • The execution is performed by the middleware during the Iteration process described above.
    • 실행은 위에서 설명한 iteration 프로세스 동안 미들웨어에 의해 수행됩니다.
    • The middleware examines each Effect description and performs the appropriate action.
    • 미들웨어는 각 효과 설명을 검사하고 적절한 조치를 수행합니다.

    take(pattern)

    Creates an Effect description that instructs the middleware to wait for a specified action on the Store. The Generator is suspended until an action that matches pattern is dispatched.

    미들웨어가 store에서 지정된 action을 기다리도록 지시하는 이펙트 명령을 만듭니다. generator는 패턴과 일치하는 aciton이 전달 될 때까지 일시 중단됩니다.

    put(action)

    Creates an Effect description that instructs the middleware to dispatch an action to the Store. This effect is non-blocking and any errors that are thrown downstream (e.g. in a reducer) will not bubble back into the saga.

    미들웨어가 action을 store에 보내도록 지시하는 이펙트 명령을 만듭니다. 이 효과는 non-blocking이고 다운 스트림(예 :reducer. 업스트림은 redux-saga가 됩니다)에 던져지는 오류는 사가에 영향을 주지 않습니다.

    call(fn, ...args)

    Creates an Effect description that instructs the middleware to call the function fn with args as arguments.

    미들웨어가 fn을 함수로, args를 인자로 받는 함수를 콜하는 명령을 하는 이펙트 description을 만듭니다.

    • fn: Function - A Generator function, or normal function which either returns a Promise as result, or any other value.
    • fn은 generator 함수나 일반 함수 모두 됩니다. 리턴값으로 프로미스 객체를 반환하거나 다른 값을 반환합니다. 
    • args: Array<any> - An array of values to be passed as arguments to fn.
    • args는 인자로 배열값을 fn에 넘깁니다.

    fork(fn, ...args)

    Creates an Effect description that instructs the middleware to perform a non-blocking call on fn.

    미들웨어가 fn에서 non-blocking 콜을 명령하는 이펙트 description을 만듭니다.

    fork, alongside race, is a central Effect for managing concurrency between Sagas.

    포크는 race()와 함께 Saga간의 concurrency를 관리하기위한 중앙 이펙트입니다.




    계속 늘어날 예정입니다.








Designed by Tistory.