npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@globality/poco

v0.3.1

Published

Opinionated, extensible React applications framework

Downloads

4

Readme

poco

Opinionated, extensible React applications framework

What is poco

Poco is a React application framework, that aims to make it easy to create applications with pre loaded services like redux, apollo client, remote configurations, etc.

Installation

yarn add @globality/poco

How to use poco

The following is an app that uses redux and react-intl.

import Poco, { IntlPlugin, ReduxPlugin } from '@globality/poco';

const App = new Poco({
    appName: 'my-app',
    createApp: () => <div>Hello world!</div>,
});

App.load((app) => {
    app.addPlugin(IntlPlugin);
    app.addPlugin(ReduxPlugin, {
        rootReducer: state => state,
    });
});

Constructor

Poco receives an object with the following properties:

  • appName (string, required)

    Application name, is used by the plugins (i.e. to determine where to load or save configuration)

  • createApp (function, required)

    Function that returns the React component that holds the application. It receives an object with:

    • container: the bottle-js service container
    • onReady: function that must be called whenever the app is ready to be shown to the user, this allows the app to load data before rendering
  • environment (object)

    Object containing basic environment configuration:

    • config: configuration object that contains the default values. Remote configurations (if enabled) will be merged into this object
    • remoteConfigs: remote configuration loader options (more about this below)

Plugins

Currently, there are a few included plug-ins:

  • ConfigurationPlugin - Loads configuration from remote URLs and localStorage
  • HistoryPlugin - Creates a history/createBrowserHistory instance
  • IntlPlugin - Wraps the app in an IntlProvider HoC from react-intl
  • ReduxPlugin - Creates a redux instance

Remote configuration

The ConfigurationPlugin is loaded by default when load() is called, and uses 3 sources for loading configuration that can be used by other plugins or in your app.

The 3 sources are:

  1. Environment: Passing a config object in the environment property will create a default configuration
  2. Remote: Loaded from one or more remote JSON files
  3. localStorage: Loaded from the browser's localStorage, intended for feature flags and session state

The different sources are loaded and merged in this order, in other words: _.merge({}, environmentConfig, remoteConfig, localConfig)

Setup

In order to load configuration from remote sources, you need to pass a remoteConfigs object to the environment property:

environment: {
    remoteConfigs: {
        enabled: true,
        origin: 'https://example.com',
        paths: ['/configs/my-app.json', '/configs/common.json'],
    },
}

TODO

  • Use React 16.3's Context API for providers.