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

github.com/4catalyzer/relay-decorators

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/4catalyzer/relay-decorators

  • v0.2.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

relay-decorators npm

Utility decorators for Relay components.

Discord

Guide

Installation

$ npm install relay-decorators

@poll(interval)

The @poll decorator sets up a wrapper component that uses setInterval to repeatedly call props.relay.forceFetch at a fixed interval (specified in milliseconds). This is not an ideal way to get updating data from a GraphQL server, but is convenient if you don't have proper subscriptions.

import React from 'react';
import Relay from 'react-relay';
import poll from 'relay-decorators/lib/poll';

// type Widget {
//   size: Int
// }

@poll(1000) // Poll every second.
class WidgetSize extends React.Component {
  static propTypes = {
    widget: React.PropTypes.object.isRequired,
  };

  render() {
    return (
      <div>The current widget size is: {this.props.widget.size}.</div>
    );
  }
}

export default Relay.createContainer(WidgetSize, {
  fragments: {
    widget: () => Relay.QL`
      fragment on Widget {
        size
      }
    `,
  },
});

If a polling component has a parent with the same poll interval, the @poll decorator will coalesce the poll timeouts to enable the queries to be batched.

FAQs

Package last updated on 18 Jul 2016

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