Alternatively, you may use the provided UMD builds directly in the
<script> tag of an HTML page. See this section.
Suppose we have a UI to fetch some user data from a remote server when a button is clicked. (For brevity, we'll just show the action triggering code.)
The Component dispatches a plain Object action to the Store. We'll create a Saga that watches for all
USER_FETCH_REQUESTED actions and triggers an API call to fetch the user data.
To run our Saga, we'll have to connect it to the Redux Store using the
There is also a UMD build of
redux-saga available in the
dist/ folder. When using the umd build
redux-saga is available as
ReduxSaga in the window object. This enables you to create Saga middleware without using ES6
import syntax like this:
The UMD version is useful if you don't use Webpack or Browserify. You can access it directly from unpkg.
The following builds are available:
If the browser you are targeting doesn't support ES2015 generators, you must transpile them (i.e., with babel plugin) and provide a valid runtime, such as the one here. The runtime must be imported before redux-saga: