Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/valtio/src/vanilla/utils/proxyWithHistory.ts>proxyWithHistory_DEPRECATED

💊 Valtio makes proxy-state simple for React and Vanilla
Go to Latest
function proxyWithHistory_DEPRECATED
Deprecated
Deprecated

Please use the valtio-history package. eg. import { proxyWithHistory } from 'valtio-history'

import { proxyWithHistory_DEPRECATED } from "https://deno.land/x/valtio@v1.13.2/src/vanilla/utils/proxyWithHistory.ts";

proxyWithHistory

This creates a new proxy with history support. It includes following properties:

  • value: any value (does not have to be an object)
  • history: an array holding the history of snapshots
  • historyIndex: the history index to the current snapshot
  • canUndo: a function to return true if undo is available
  • undo: a function to go back history
  • canRedo: a function to return true if redo is available
  • redo: a function to go forward history
  • saveHistory: a function to save history

[Notes] Suspense/promise is not supported.

Examples

import { proxyWithHistory } from 'valtio/utils' const state = proxyWithHistory({ count: 1, })

Parameters

initialValue: V
optional
skipSubscribe = [UNSUPPORTED]