webmiddle

webmiddle

  • Getting Started
  • GitHub

›Storing

Introduction

  • Getting Started
  • Main concepts
  • Starter App

webmiddle

  • Evaluate
  • Resources
  • ErrorBoundary
  • WithOptions

Control Flow

  • Pipe
  • Parallel

Fetching

  • HttpRequest
  • Browser
  • Cookie Manager

Transforming

  • CheerioToJson
  • JSONSelectToJson

Storing

  • Resume

Remote execution

  • Server
  • Client

Resume

A component that makes a task resumable by caching the result.

Install

yarn webmiddle-component-resume

Properties

NameDescription
savePathThe filesystem path where the result should be saved.
taskTask that should be resumable.

Usage

import { PropTypes, rootContext } from 'webmiddle';
import Resume from 'webmiddle-component-resume';

const SubComponent = () => 'foo';

const MyComponent = () => (
  <Resume savePath="./cache/resource1" task={
    <SubComponent />
  }/>
);

rootContext.evaluate(<MyComponent />)
.then(resource => {
  console.log(resource.name); // "foo"
});

How it works

Evaluates the task, the result is wrapped into a x-webmiddle-type resource, so to preserve any Resource and Virtual objects, then saves it to the filesystem.

On subsequent executions, the component checks if the result is already stored in the filesystem, if so it just returns such result.

Since the result is stored in the filesystem, it will last even among different executions of the application. This makes possible to resume work in case the application terminated abruptly and in other similar scenarios.

The save path is specified via the savePath property, which is relative to the outputBasePath context option.

← PreviousNext →
  • Install
  • Properties
  • Usage
  • How it works
webmiddle
Docs
Getting StartedMain ConceptsStarter App
Community
Stack OverflowTwitter
More
GitHubStar
Copyright © 2018 Manuel Dell'Elce