0.5.3 • Published 4 months ago

@ic-reactor/store v0.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

IC-ReActor - Store

@ic-reactor/store is a state management library designed for applications interacting with the Internet Computer (IC) blockchain. It facilitates the management of actor states, authentication processes, and seamless interaction with IC actors, leveraging the power of zustand for global state management.

Features

  • Actor State Management: Efficiently manage and update the state of IC actors.
  • Authentication Handling: Integrated functionality for managing authentication with IC.
  • Zustand Integration: Utilize zustand for global state management in a React-friendly way.
  • Error and Loading State Management: Easily handle loading states and errors across your application.
  • Asynchronous Interaction Support: Built-in support for managing asynchronous interactions with IC actors.

Installation

Install the package using npm:

npm install @ic-reactor/store

or using yarn:

yarn add @ic-reactor/store

Usage

To use @ic-reactor/store, start by creating a ReActor manager with your actor configurations:

import createReActorManager from "@ic-reactor/store"
import { idlFactory, canisterId } from "./declarations/actor"

type Actor = typeof actor

const { actorStore, authenticate, callMethod } = createReActorStore<Actor>({
  idlFactory,
  canisterId: "xeka7-ryaaa-aaaal-qb57a-cai",
  host: "https://icp-api.io",
})

Managing Actor State

Utilize the ReActor manager to manage the state of your IC actors:

// Access and update actor state
const actorState = actorStore.getState()

Handling Authentication

Manage authentication states and processes:

// Authenticate with the IC blockchain
authenticate()
  .then(() => {
    // Handle successful authentication
  })
  .catch((error) => {
    // Handle authentication errors
  })

Calling Actor Methods

Call actor methods and handle the results:

// Call an actor method
callMethod({
  functionName: "get_balance",
  args: [principal],
})
  .then((result) => {
    // Handle successful method call
  })
  .catch((error) => {
    // Handle method call errors
  })

API Reference

@ic-reactor/store provides several key functionalities:

  • ReActorManager: The main class to manage actor states and interactions.
  • createReActorManager: Factory function to create a new ReActor manager instance.
  • State management actions: Methods to initialize actors, handle authentication, and manage global state.

For a detailed API reference, including the complete list of methods and their usage, please refer to the documentation.

Contributing

Contributions to @ic-reactor/store are welcome! Please read our contributing guidelines for more information.

License

@ic-reactor/store is licensed under the MIT License. See the LICENSE file for more details.

0.5.3

4 months ago

0.5.2

4 months ago

0.5.1

4 months ago

0.4.1

4 months ago

0.4.0

4 months ago

0.4.3

4 months ago

0.4.2

4 months ago

0.3.5

4 months ago

0.3.4

4 months ago

0.3.0

4 months ago

0.3.2

4 months ago

0.3.1

4 months ago

0.3.3

4 months ago

0.2.10

4 months ago

0.2.9

4 months ago

0.2.8

4 months ago

0.2.7

4 months ago

0.2.6

4 months ago

0.2.5

4 months ago

0.2.4

4 months ago

0.2.3

5 months ago

0.2.1

5 months ago

0.2.0

5 months ago

0.2.2

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago

0.0.6

5 months ago

0.0.3

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago