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

nalanda

v0.2.3

Published

<p align="center"> <a href="https://nalanda.bangle.io"> <img src="https://raw.githubusercontent.com/bangle-io/nalanda/dev/documentation/public/nalanda.png" alt="screen" width="128" > </a> </p> <h2 align="center"> Nalanda </h2>

Downloads

19

Readme

Features

  • Predictable State Management: No magic, predictable state management that scales with your app.
  • Performance Optimized: With explicit dependency management, slices of state only update when necessary, ensuring optimal performance.
  • TypeScript First: Leverages TypeScript to catch errors at compile-time.
  • Powerful Effects System: Handle complex logic outside of your UI components.
  • Scalability: Allows you to break your app into small, testable, and maintainable slices.
  • Framework Agnostic: Works seamlessly with any framework.

Installation

npm i @nalanda/core

# for react
npm i @nalanda/react

Quick Start

Creating a Slice

Lets start by creating a simple counter slice.

import { createKey } from '@nalanda/core';

// The key is a local helper used to define various components of your slice.
const key = createKey('counterSlice', []);

// State fields define part of your state.
const counter = key.field(0);

// Actions define how a field/s should be updated.
function increment() {
  return counter.update((c) => c + 1);
}

// A slice serves as an interface, revealing the specified fields
// and actions to the entire application.
export const counterSlice = key.slice({
  counter,
  increment,
});

Setting up the Store

At the root of your React app, set up a store and encapsulate your app with the StoreProvider component:

import { StoreProvider } from '@nalanda/react';
import { createStore } from '@nalanda/core';
import { counterSlice } from './counter-slice';

// Establish a global store incorporating your slices.
const store = createStore({
  slices: [counterSlice],
});

ReactDOM.render(
  // use the StoreProvider to make the store available to the entire app.
  <StoreProvider store={store}>
    <App />
  </StoreProvider>,
  document.getElementById('root'),
);

Displaying the counter

With the store in place, employ the useSlice hook to access the state and actions from the slice:

import { useTrack, useStore } from '@nalanda/react';
import { counterSlice } from './counter-slice';

export function Counter() {
  // useTrack re-render the component whenever `counter` changes
  const { counter } = useTrack(counterSlice);
  const store = useStore();

  const increment = () => {
    // Dispatch an action to update the slice
    store.dispatch(counterSlice.increment());
  };

  return (
    <div>
      <h1>Counter</h1>
      <p>{counter}</p>
      <button onClick={increment}>increment</button>
    </div>
  );
}

Next Steps

Contribute to Nalanda

Your contribution can make nalanda even better! If you're interested in lending a hand, please consult our CONTRIBUTING.md guide.