Socket
Socket
Sign inDemoInstall

jotai

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jotai - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

29

index.cjs.js

@@ -100,3 +100,6 @@ 'use strict';

var createAtomState = function createAtomState(prevState, atom, dependent) {
addDependent(dependentsMap, atom, dependent);
if (dependent) {
addDependent(dependentsMap, atom, dependent);
}
var partialState = new Map();

@@ -346,5 +349,3 @@ var atomState = prevState.get(atom);

function atom(read, write) {
var instance = {
initialValue: null
};
var instance = {};

@@ -361,5 +362,5 @@ if (typeof read === 'function') {

});
} else {
instance.initialValue = value;
}
instance.initialValue = value;
} else {

@@ -392,5 +393,14 @@ instance.initialValue = read;

var atomState = state.get(atom);
if (!atomState) return atom.initialValue;
if (atomState.promise) return atomState.promise;
return atomState.value;
if (atomState) {
return atomState.promise || atomState.value;
}
if (atom.initialValue instanceof Promise) {
atom.initialValue.then(function () {
actions.init(null, atom);
});
}
return atom.initialValue;
}, [atom]));

@@ -416,2 +426,3 @@ var setAtom = react.useCallback(function (update) {

react.useDebugValue(promiseOrValue);
return [promiseOrValue, setAtom];

@@ -418,0 +429,0 @@ }

@@ -96,3 +96,6 @@ var jotai = (function (exports, react, useContextSelector) {

var createAtomState = function createAtomState(prevState, atom, dependent) {
addDependent(dependentsMap, atom, dependent);
if (dependent) {
addDependent(dependentsMap, atom, dependent);
}
var partialState = new Map();

@@ -342,5 +345,3 @@ var atomState = prevState.get(atom);

function atom(read, write) {
var instance = {
initialValue: null
};
var instance = {};

@@ -357,5 +358,5 @@ if (typeof read === 'function') {

});
} else {
instance.initialValue = value;
}
instance.initialValue = value;
} else {

@@ -388,5 +389,14 @@ instance.initialValue = read;

var atomState = state.get(atom);
if (!atomState) return atom.initialValue;
if (atomState.promise) return atomState.promise;
return atomState.value;
if (atomState) {
return atomState.promise || atomState.value;
}
if (atom.initialValue instanceof Promise) {
atom.initialValue.then(function () {
actions.init(null, atom);
});
}
return atom.initialValue;
}, [atom]));

@@ -412,2 +422,3 @@ var setAtom = react.useCallback(function (update) {

react.useDebugValue(promiseOrValue);
return [promiseOrValue, setAtom];

@@ -414,0 +425,0 @@ }

@@ -1,2 +0,2 @@

import { useLayoutEffect, useEffect, useState, useRef, useMemo, createElement, useCallback } from 'react';
import { useLayoutEffect, useEffect, useState, useRef, useMemo, createElement, useCallback, useDebugValue } from 'react';
import { createContext, useContext, useContextSelector } from 'use-context-selector';

@@ -98,3 +98,6 @@

const createAtomState = (prevState, atom, dependent) => {
addDependent(dependentsMap, atom, dependent);
if (dependent) {
addDependent(dependentsMap, atom, dependent);
}
const partialState = new Map();

@@ -321,5 +324,3 @@ let atomState = prevState.get(atom);

function atom(read, write) {
const instance = {
initialValue: null
};
const instance = {};

@@ -334,5 +335,5 @@ if (typeof read === 'function') {

});
} else {
instance.initialValue = value;
}
instance.initialValue = value;
} else {

@@ -361,5 +362,14 @@ instance.initialValue = read;

const atomState = state.get(atom);
if (!atomState) return atom.initialValue;
if (atomState.promise) return atomState.promise;
return atomState.value;
if (atomState) {
return atomState.promise || atomState.value;
}
if (atom.initialValue instanceof Promise) {
atom.initialValue.then(() => {
actions.init(null, atom);
});
}
return atom.initialValue;
}, [atom]));

@@ -385,2 +395,3 @@ const setAtom = useCallback(update => {

useDebugValue(promiseOrValue);
return [promiseOrValue, setAtom];

@@ -387,0 +398,0 @@ }

{
"name": "jotai",
"private": false,
"version": "0.3.0",
"version": "0.3.1",
"description": "👻 Next gen state management that will spook you",

@@ -6,0 +6,0 @@ "main": "index.cjs.js",

@@ -5,3 +5,3 @@ <p align="center">

[![Build Size](https://img.shields.io/bundlephobia/min/jotai?label=bunlde%20size&style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/result?p=jotai)
[![Build Size](https://img.shields.io/bundlephobia/min/jotai?label=bundle%20size&style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/result?p=jotai)
[![Build Status](https://img.shields.io/travis/react-spring/jotai/master?style=flat&colorA=000000&colorB=000000)](https://travis-ci.org/react-spring/jotai)

@@ -11,3 +11,3 @@ [![Version](https://img.shields.io/npm/v/jotai?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/jotai)

Jotai is pronounced "jaw-tie" and means "state" in Japanese.
Jotai is pronounced "joe-tie" and means "state" in Japanese.

@@ -102,4 +102,4 @@ You can try a live demo [here](https://codesandbox.io/s/jotai-demo-47wvh).

```jsx
const urlAtom = create("https://json.host.com")
const fetchUrlAtom = create(
const urlAtom = atom("https://json.host.com")
const fetchUrlAtom = atom(
async get => {

@@ -151,3 +151,3 @@ const response = await fetch(get(urlAtom))

```jsx
const fetchCountAtom = create(
const fetchCountAtom = atom(
get => get(countAtom),

@@ -154,0 +154,0 @@ async (_get, set, url) => {

import { Getter, Setter, Atom, WritableAtom, NonPromise, NonFunction, SetStateAction } from './types';
export declare function atom<Value, Update>(read: (get: Getter) => NonPromise<Value>, write: (get: Getter, set: Setter, update: Update) => void | Promise<void>): WritableAtom<Value, Update>;
export declare function atom<Value, Update>(read: NonFunction<NonPromise<Value>>, write: (get: Getter, set: Setter, update: Update) => void | Promise<void>): WritableAtom<Value, Update>;
export declare function atom<Value, Update>(read: (get: Getter) => Promise<Value>, write: (get: Getter, set: Setter, update: Update) => void | Promise<void>): WritableAtom<Value | null, Update>;
export declare function atom<Value, Update>(read: (get: Getter) => Promise<Value>, write: (get: Getter, set: Setter, update: Update) => void | Promise<void>): WritableAtom<Value | Promise<Value>, Update>;
export declare function atom<Value>(read: (get: Getter) => NonPromise<Value>): Atom<Value>;
export declare function atom<Value>(read: (get: Getter) => Promise<Value>): Atom<Value | null>;
export declare function atom<Value>(read: (get: Getter) => Promise<Value>): Atom<Value | Promise<Value>>;
export declare function atom<Value>(initialValue: NonFunction<NonPromise<Value>>): WritableAtom<Value, SetStateAction<Value>>;
import React from 'react';
import { AnyAtom, AnyWritableAtom } from './types';
export declare type Actions = {
init: (id: symbol, atom: AnyAtom) => void;
init: (id: symbol | null, atom: AnyAtom) => void;
dispose: (id: symbol) => void;

@@ -6,0 +6,0 @@ write: (atom: AnyWritableAtom, update: unknown) => void;

@@ -1,3 +0,3 @@

import { Atom, WritableAtom } from './types';
export declare function useAtom<Value, Update>(atom: WritableAtom<Value, Update>): [Value, (update: Update) => void];
export declare function useAtom<Value>(atom: Atom<Value>): [Value, never];
import { Atom, WritableAtom, NonPromise } from './types';
export declare function useAtom<Value, Update>(atom: WritableAtom<Value, Update>): [NonPromise<Value>, (update: Update) => void];
export declare function useAtom<Value>(atom: Atom<Value>): [NonPromise<Value>, never];
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