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

restater

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restater - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

3

dist/interfaces/interfaces.d.ts

@@ -33,1 +33,4 @@ /// <reference types="react" />

}
export interface IAsyncStateOptions {
skipLoading?: boolean;
}

4

dist/useAsyncStore.d.ts
/// <reference types="react" />
import { IAsyncContext, AsyncPayload } from './interfaces/interfaces';
import { IAsyncContext, AsyncPayload, IAsyncStateOptions } from './interfaces/interfaces';
/**

@@ -8,3 +8,3 @@ * Returns an async payload from a store, and a function to update it.

*/
declare const useAsyncStore: <T, K extends keyof T>(context: import("react").Context<IAsyncContext<T>>, key: K) => [{ [K_1 in keyof T]: AsyncPayload<T[K_1]>; }[K], (promise: Promise<T[K]>) => Promise<void>];
declare const useAsyncStore: <T, K extends keyof T>(context: import("react").Context<IAsyncContext<T>>, key: K) => [{ [K_1 in keyof T]: AsyncPayload<T[K_1]>; }[K], (promiseOrCallback: Promise<T[K]> | ((currentValue: { [K_2 in keyof T]: T[K_2]; }[K]) => Promise<T[K]>), options?: IAsyncStateOptions | undefined) => Promise<void>];
export { useAsyncStore };

@@ -54,16 +54,19 @@ "use strict";

outerStore[key] = store[key];
var setState = function (promiseOrCallback) { return __awaiter(void 0, void 0, void 0, function () {
var setState = function (promiseOrCallback, options) { return __awaiter(void 0, void 0, void 0, function () {
var callback, data, promise, data, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
setStore({ prop: key, payload: { state: 'loading' } });
_a.label = 1;
if (!(options === null || options === void 0 ? void 0 : options.skipLoading)) {
setStore({ prop: key, payload: { state: 'loading' } });
}
_b.label = 1;
case 1:
_a.trys.push([1, 6, , 7]);
_b.trys.push([1, 6, , 7]);
if (!(typeof promiseOrCallback === 'function')) return [3 /*break*/, 3];
callback = promiseOrCallback;
return [4 /*yield*/, callback(outerStore[key])];
return [4 /*yield*/, callback((_a = outerStore[key]) === null || _a === void 0 ? void 0 : _a.data)];
case 2:
data = _a.sent();
data = _b.sent();
setStore({ prop: key, payload: { state: 'completed', data: data } });

@@ -75,8 +78,8 @@ return [3 /*break*/, 5];

case 4:
data = _a.sent();
data = _b.sent();
setStore({ prop: key, payload: { state: 'completed', data: data } });
_a.label = 5;
_b.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
error_1 = _a.sent();
error_1 = _b.sent();
setStore({ prop: key, payload: { state: 'failed', error: error_1 } });

@@ -83,0 +86,0 @@ return [3 /*break*/, 7];

{
"name": "restater",
"version": "0.0.11",
"version": "0.0.12",
"description": "Tiny hook-based state management tool for React",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -185,2 +185,11 @@ # Restater · [![NPM Version](https://img.shields.io/npm/v/restater)](https://www.npmjs.com/package/restater) ![Build Status](https://github.com/Silind-Software/restater/workflows/build/badge.svg)

When using an Async Store, the `setUsername` function takes an optional `options` object as the second argument:
```javascript
setUsername(getUpdatedUsername(), { skipLoading: true });
```
Setting `skipLoading` to `true` will bypass the `loading` step.
This will make `username.state` go directly from `initial` to `completed` or `failed`.
If ``username.state` is already in `completed`, it will stay there, or go to `failed`.
### Helper functions

@@ -187,0 +196,0 @@

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