New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@abadi199/remotedata

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abadi199/remotedata

A DataType Representing Remote Data

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by83.33%
Maintainers
1
Weekly downloads
 
Created
Source

RemoteData for TypeScript

Inspired by Kris Jenkin's Elm RemoteData package and his blog post: http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html

Example

function renderFruits(RemoteData<string[], string> fruits) {
    switch (fruits.kind) {
      case RemoteDataKind.Loading:
        renderLoading();
        break;
      case RemoteDataKind.Error:
        renderError(fruits.error);
        break;
      case RemoteDataKind.ErrorWithData:
        renderErrorWithData(fruits.value, fruits.error);
        break;
      case RemoteDataKind.NotAsked:
        clear();
        break;
      case RemoteDataKind.Reloading:
        renderReloading(fruits.value);
        break;
      case RemoteDataKind.Success:
        renderSuccess(fruits.value);
        break;
    }
} 

function main() {
    renderFruits(success(["Apple", "Orange", "Mango"])); // Success
    renderFruits(loading()); // Loading
    renderFruits(error("Error loading fruits")); // Error
    renderFruits(loading(success(["Apple", "Orange", "Mango"])); // Reloading
    renderFruits(error("", success(["Apple", "Orange", "Mango"]))); // ErrorWithData
}

Install

npm install -S @abadi199/remotedata

Contributing

  • Submit a pull request! If you're missing a feature you want to have, or just found a bug, or found an error in the docs, please submit a pull request.
  • Create an issue! If you found a bug or want a new feature that you think will make the library better, but don't have time to do it yourself, please submit an issue.

FAQs

Package last updated on 29 Aug 2018

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