webmiddle

webmiddle

  • Getting Started
  • GitHub

›webmiddle

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

ErrorBoundary

A component used for error handling

Properties

NameDescription
retries (optional)The number of retries, defaults to zero. Use a negative number for unlimited retries.
isRetryable (optional)Function that given the error returns a boolean stating if a retry should be attempted. Defaults to a function that always return true.
tryValue that should be evaluated.
catch (optional)Function called in case no further retries can be attempted. Gets the error as parameter and must return the value to use as fallback. If this property is not specified, then the error will be thrown instead.

Usage

import { rootContext, ErrorBoundary } from 'webmiddle';

const FallbackComponent = (props, context) => context.createResource(
  "result",
  "text/plain",
  "fallback"
);

const ThrowComponent = () => {
  throw new Error('expected fail');
};

const Component = () => (
  <ErrorBoundary
    retries={-1}
    isRetryable={err => err.message !== 'expected fail'}
    try={
      <ThrowComponent />
    }
    catch={
      err => <FallbackComponent />
    }
  />
);

rootContext.evaluate(
  <Component />
).then(resource => {
  console.log(resource.content); // "fallback"
});

How it works

Evaluates its only child by wrapping it in a try...catch and allowing for retries and catch handling.

A negative retries number means unlimited retries.

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