Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dreamworld/async-tasks

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dreamworld/async-tasks

It's used to manage async tasks on redux

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Async Tasks

  • It is used to manage async tasks with redux state.

Usage pattern

Activate reducer on slice (Required)
import * as asyncTasks from '@dreamworld/async-tasks';
import { store } from "path/to/store";

asyncTask.init(store);
Use Generator function to run any async task
Foreground task
import { run } from '@dreamworld/async-tasks';

try {
  const result = yield call(run, taskId, fn, timeoutMillis);
} catch (e) {
  //handle error
}
Background task
import { run } from '@dreamworld/async-tasks';

try {
  const taskId = yield fork(run, taskId, fn, timeoutMillis);
  yield cancel(taskId);
} catch (e) {
  //handle error
}
To retrieve the result of a Task from another Saga
import { taskResult } from '@dreamworld/async-tasks';

try {
  const result = yield call(taskResult, taskId);
} catch (e) {
  //if Task failed.
}

Selectors
  • Task get(id): Returns Task of given id.
  • String status(id): Returns current status of given taskId
  • Object result(id): Returns result of given taskId

It manages state at below path.

Path: ___DW_asyncTasks.$taskId

namedata typedescription
statusStringPossible values: IN_PROGRESS, SUCCESS and FAILED.
startedAtNumberWhat Task execution is started
completedAtNumberWhen Task is completed; status changed to SUCCESS or FAILED.
resultObjectTask result. Promise resolved with this
errorErrorString

FAQs

Package last updated on 12 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc