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

hyperapp-loadable

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

hyperapp-loadable

Experimental package to provide react-loadable like behavior to hyperapp

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

hyperapp-loadable

WIP This package is inspired be react-loadable. The main difference between the two packages is that this package targets hyperapp instead of react and thus does not have stateful components.

To work around this difference we use a mixin to provide a { loadable: {} } in the state as well as add actions: { loadable: { loaded: () => any }} for triggering an update/re-render after lazy-loaded module is available.

/* src/Test.js */
import { h } from "hyperapp";

export function Test(state, actions) {
  return (
    <div>{"Testing lazy-loaded component!"}</div>
  );
}
import { h, app } from "hyperapp";
import Loadable from "hyperapp-loadable";

const Loading = (state, actions) => <div>{"Loading..."}</div>;

app({
  view: (state, actions) => {
    return (<Loadable 
      state={state}
      actions={actions}
      name={"/Test"}
      loader={() => import("./Test")}
      loading={Loading}
      loaded={actions.loadable.loaded} /* not required defaults too actions.loadable.loaded */
    />);
  },
  mixins: [Loadable]
});

License

hyperapp-loadable is MIT licensed. See LICENSE.

FAQs

Package last updated on 26 Aug 2017

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