New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tauri-plugin-state

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tauri-plugin-state

## A Stupid simple state management plugin for Tauri

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
 
Created
Source

Tauri Plugin state

A Stupid simple state management plugin for Tauri

Let's say you want to manage state between your frontend and backend, but you want to keep it in sync and completely managed from rust.

This plugin is for you.

Frontend Framework guides

By default, we use a simple Map object to store state on the frontend. If you need reactivity, frameworks have their own reactive Map implementations that you can use.

  • Svelte: import { Map } from 'svelte/reactivity';
  • Vue: You can wrap a map in a reactive object. setupState(reactive(new Map()));
  • SolidJS: You can use https://primitives.solidjs.community/package/map to create a reactive map. import { ReactiveMap } from "@solid-primitives/map";
  • React: N/A. No idea how to do this in React. Make a PR if you know how.

Manually watching for state changes

All state changes are broadcasted to the frontend via Tauri's native event API. You can listen for these changes by listening to the plugin:state-change event.

import { listen } from '@tauri-apps/api/event'

listen<{ key: string, value: unknown }>('plugin:state-change', (event) => {
    const { key, value } = event.payload
    console.log(`State change for key ${key} with value ${value}`)
})

How you type value is up to you. We recommend using a discriminated union to type the value.

Panic guide

This plugin considers not being able to sync state as an invariant violation and will panic if it can't sync state. We always want to be in sync to make sure nothing goes wrong.

FAQs

Package last updated on 26 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc