Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable */
import * as React from 'react';
import { createContextStore, Action, action } from 'easy-peasy';
interface StoreModel {
count: number;
inc: Action;
}
interface InitialData {
count: number;
}
const Counter = createContextStore({
count: 0,
inc: action(state => {
state.count += 1;
}),
});
const CounterWithInitializer = createContextStore(
data => ({
count: data ? data.count + 1 : 0,
inc: action(state => {
state.count += 1;
}),
}),
);
function CountDisplay() {
count: number;
inc: Action;
}
interface InitialData {
count: number;
}
const Counter = createContextStore({
count: 0,
inc: action(state => {
state.count += 1;
}),
});
const CounterWithInitializer = createContextStore(
data => ({
count: data ? data.count + 1 : 0,
inc: action(state => {
state.count += 1;
}),
}),
);
function CountDisplay() {
const count = Counter.useStoreState(state => state.count);
const inc = Counter.useStoreActions(actions => actions.inc);
return (
<>
<div>{count + 1}</div>
<button type="button">
+</button>
state.value = payload;
}),
};
export interface ServerStore {
server: ServerDataStore;
subusers: ServerSubuserStore;
databases: ServerDatabaseStore;
files: ServerFileStore;
schedules: ServerScheduleStore;
socket: SocketStore;
status: ServerStatusStore;
clearServerState: Action;
}
export const ServerContext = createContextStore({
server,
socket,
status,
databases,
files,
subusers,
schedules,
clearServerState: action(state => {
state.server.data = undefined;
state.server.permissions = [];
state.databases.data = [];
state.subusers.data = [];
state.files.directory = '/';
state.files.selectedFiles = [];
state.schedules.data = [];