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

parkgate-io-hooks

v1.0.7

Published

Library for Parkgate IO plaform integration

Downloads

282

Readme

Parkgate IO Hooks

Library for Parkgate IO plaform integration for a Developer Application

NPM JavaScript Style Guide

Parkgate IO Hooks is a frontend side library used for applications rendered on the Parkgate IO Platform. Using a React Hooks API, implementers have access to features provided by the platform.

Features

  • Get initial state of application
  • Listen to changes in application window dimensions
  • Communicate with shared data accross multiple associated applications on a board
  • More features coming soon!

Install

npm install --save parkgate-io-hooks

Parkgate IO Provider

The ParkgateProvider should be placed at the root of the application. Internaly using the React Context API, the provider manages the data-flow of the application. Parkgate IO Hooks must be instantiated inside components nested within the ParkgateProvider and not the same component.

Once an application is wrapped in the provider, the application will be not render useless within the Parkgate IO Platform experience. A developer testing evironment is still in development and will be posted soon. Stay tuned!

Usage

// Root of your application
import React from 'react';

import { ParkgateProvider } from 'parkgate-io-hooks';

const App = () => {
    return (
        <ParkgateProvider>
            <MyComponent />
        </ParkgateProvider>
    );
};
export default App;

Hooks API

Parkgate IO features can be accessed by Parkgate IO Hooks. Hooks are only valid in components nested within the root ParkgateProvider.

useParkgateData

Returns configuration data of the application; used to specify initial state of the application

Usage

import React from 'react'

import { useParkgateData } from 'parkgate-io-hooks'

const MyComponent = () => {
    const data = useParkgateData();
    return <p> {JSON.stringify(data)} </p>;
}
export default MyComponent;

Returns: Object (key/value data specified in application config)

useParkgateDimensions

Returns dimension properties updated on screen resize

Usage

import React from 'react';

import { useParkgateDemensions } from 'parkgate-io-hooks';

const MyComponent = () => {
    const {
        shape,
        width,
        height,
    } = useParkgateDemensions();
    
    return <p> Shape: {shape}, Width: {width}, Height: {height} </p>;
}
export default MyComponent;

Returns Object (Dimensions Schema)

| Property | Type | Description | Values | | --- | --- | --- | --- | | shape | String | String representation of current shape of the application window. possibly used as a class name for style logic. | large-square, small-square, horizontal-rectangle, vertical-rectangle, modal-square, fullscreen | | width | number | Parkgate width unit representing a multiple of 90px | 3 (small) or 5(large) or 7 (modal) or null (fullscreen) | | height | number | Parkgate height unit representing a multiple of 90px | 3 (small) or 5(large) or 7 (modal) or null (fullscreen) |

useParkgateStore

Applications on the Parkgate platform can share data amongst themselves using registered stores. You application can access and update the shared value using this hook. The desired store is indexed using the registered store key. It follows the same api as the useState hook.

Usage

import React from 'react';

import { useParkgateStore } from 'parkgate-io-hooks';

const MyComponent = () => {
    // Indexes the registered store `Count`
    // Similar API to `useState`
    const [
        count,
        setCount,
     ] = useParkgateStore('count');

     const incrementCount => () => {
         setCount(count++);
     };
    
    return (
        <>
            <p> Count {count}</p>
            <button onClick={incrementCount.bind(this)}>Increment</button>
        </>
    );
}
export default MyComponent;

Parameters

| Name | Type | Description | | --- | --- | --- | | StoreKey | String | Used the index the sprecific store registered with this application to display or modify its state |

Returns Array<StoreValue, SetStoreFunction>

| Array Index | Name | Description | Value | | --- | --- | --- | --- | | 0 | Store Value | The value stored in the specified shared store | any | | 1 | Set Store Function | A function that updates the shared store state | Function<any> |

finishParkgateProcess

Nested applications or Modal applications can close themselves by calling the provided function. The parameter provided to this function passes a return value of the experience to the parkgate platform. This function is not effective if called in a board application instance.

Usage

import React from 'react';

import { finishParkgateProcess } from 'parkgate-io-hooks';

const MyComponent = () => {
    let computedValue = 42

     const closeApplication = () => {
         finishParkgateProcess(42);
     };
    
    return <button onClick={closeApplication}>Close</button>;
}
export default MyComponent;

Parameters

| Name | Type | Description | | --- | --- | --- | | ReturnValue | Any | The final value returned by the application instance before the closure of the application is initiated. |

Returns undefined


License

MIT © ParkgateIO

This hook is created using create-react-hook.