Socket
Book a DemoInstallSign in
Socket

@jvlk/fp-ts-remote-data

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jvlk/fp-ts-remote-data

An fp-ts library to make it easy to work with remote data.

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

@jvlk/fp-ts-remote-data

A library to make it easy to work with remote data. Compatible with the fp-ts ecosystem, but it's not required.

RemoteData represents a value that can be in one of four states:

  • Loading
  • Error
  • Empty
  • Success

Example in React

import * as D from '@jvlk/fp-ts-remote-data'
import { pipe } from 'fp-ts/function'

import useBlogRequest from './useBlogRequest'
import Loading from './Loading'
import Error from './Error'
import Empty from './Empty'
import Blog from './Blog'

function Component() {
  const blog = useBlogRequest()

  return pipe(
    blog,
    D.fold(
        () => <Loading />),
        err => <Error error={err}>,
        () => <Empty/>,
        entries => <Blog entries={entries}>
  )
}

Installation

Using NPM:

npm i @jvlk/fp-ts-remote-data

Using Yarn:

yarn add @jvlk/fp-ts-remote-data

Thanks

The start of this repo began as a clone of https://github.com/sylcastaing/fp-ts-remote-data. I have modified it and diverged from it. That library is much more "sound" from a fp-ts types perspective, but I wanted to create something that was focused more on developer usability. I've removed many of the functions in favor of simplifying things. I have also added the 4th state of empty to avoid having to use a value of Option if the results don't contain any data.

The original concept of the RemoteData type comes from How Elm Slays a UI Antipattern.

Keywords

remote-data

FAQs

Package last updated on 14 May 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.