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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mapples/action

v1.0.3

Published

A React Native action management package that provides a centralized way to handle and track user actions throughout your application using RxJS observables.

Readme

@mapples/action

A React Native action management package that provides a centralized way to handle and track user actions throughout your application using RxJS observables.

Features

  • 🎯 Action Tracking: Centralized action store using RxJS Subject for reactive action handling
  • 🔒 Type Safety: Full TypeScript support with comprehensive type definitions
  • ⚛️ React Integration: Seamless integration with React hooks and context
  • 🎁 Flexible Payload: Support for custom action payloads and event data
  • 🏗️ Provider Pattern: Easy setup with ActionProvider component

Installation

npm install @mapples/action
# or
yarn add @mapples/action

Usage

Basic Setup

Wrap your app with the ActionProvider to enable action tracking:

import React from 'react';
import ActionProvider from '@mapples/action';

function App() {
  const handleAction = (action) => {
    console.log('Action triggered:', action);
    // Handle the action (e.g., analytics, logging, state updates)
  };

  return (
    <ActionProvider onAction={handleAction}>
      {/* Your app components */}
    </ActionProvider>
  );
}

Using the Action Store

Access the action store in your components using the useActionStore hook:

import React from 'react';
import { useActionStore } from '@mapples/action';

function MyComponent() {
  const actionStore = useActionStore();

  const handleButtonPress = () => {
    // Emit an action
    actionStore.next({
      time: Date.now(),
      type: 'BUTTON_PRESSED',
      payload: {
        data: { buttonId: 'submit' },
        originalEventData: ['button', 'press'],
      },
    });
  };

  return <button onPress={handleButtonPress}>Submit</button>;
}

Action Types

The package provides the following TypeScript interfaces:

interface Action {
  time: number; // Timestamp when action occurred
  type?: string; // Action type identifier
  payload?: ActionPayload; // Optional payload data
}

interface ActionPayload {
  originalEventData?: any[]; // Original event data
  data?: any; // Custom data payload
}

API Reference

ActionProvider

A React context provider that manages the action store and handles action subscriptions.

Props:

  • onAction: (action: Action) => void - Callback function called when an action is emitted
  • children: ReactNode - Child components

useActionStore

A React hook that provides access to the action store.

Returns:

  • Subject<Action> - RxJS Subject for emitting and subscribing to actions

Example:

const actionStore = useActionStore();

// Emit an action
actionStore.next({
  time: Date.now(),
  type: 'USER_LOGIN',
  payload: { data: { userId: '123' } },
});

// Subscribe to actions (if needed)
useEffect(() => {
  const subscription = actionStore.subscribe((action) => {
    console.log('New action:', action);
  });

  return () => subscription.unsubscribe();
}, [actionStore]);

Advanced Usage

Custom Action Types

Define custom action types for better type safety:

type CustomActionType =
  | 'USER_LOGIN'
  | 'USER_LOGOUT'
  | 'BUTTON_PRESSED'
  | 'FORM_SUBMITTED';

interface CustomAction extends Action {
  type: CustomActionType;
  payload: {
    data: any;
    originalEventData?: any[];
  };
}

Action Middleware

You can create middleware to process actions before they reach the main handler:

function createActionMiddleware(store: Subject<Action>) {
  return store.pipe(
    // Add timestamp if missing
    map((action) => ({
      ...action,
      time: action.time || Date.now(),
    })),
    // Filter out invalid actions
    filter((action) => action.type && action.type.length > 0),
  );
}

Best Practices

  1. Consistent Action Types: Use consistent naming conventions for action types (e.g., COMPONENT_ACTION format)

  2. Meaningful Payloads: Include relevant data in action payloads for better debugging and analytics

  3. Error Handling: Always handle potential errors in your action handlers

  4. Performance: Be mindful of action frequency to avoid performance issues

  5. Testing: Test your action flows to ensure they work as expected

License

MIT

Author

Oleksandr Soloviov - mapples.org