New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@antmjs/global-state

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antmjs/global-state

全局UI缓存解决方案

latest
Source
npmnpm
Version
1.21.3
Version published
Maintainers
1
Created
Source

@antmjs/global-state

全局 UI 数据缓存解决方案

为什么需要

我所理解的缓存分 4 类,1: 和 UI 无关的临时缓存;2: 和 UI 无关的本地缓存; 3: 和 UI 相关的全局缓存; 4: 和 UI 相关的局部缓存。本仓库解决的就是 3 的问题。 众所周知,这一类的解决方案其实有很多,比如 redux、mobx,重点其实在于我们的项目适不适合这些比较重的解决方案。结合面试者的回答,有都走 redux 的,有请求走 redux 的,有自己约定的。其实都是在找一个临界点,而这个临界点结合业务以及一线小伙伴的理解都会产生不一样的结果,最终 redux 就成了一个黑洞。 我现在更倾向于少用,当然不是不用,而是可枚举的用(你很清楚里面存储了什么东西,和你使用@antmjs/cache 这个库一样,你很清楚你定义了哪些 key),而且由负责人维护,结合 hooks,业务开发者只管取值。可以看看模版

安装

yarn add @antmjs/global-state

使用

import GlobalState from '@antmjs/global-state'

const {
  Provider,
  useGlobalState,
  useGlobalLoading,
  useGlobalError,
  useUpdate,
  useFetchAndUpdate,
} = GlobalState(
  { user: {} },
  {
    user: async function () {
      /** await getUser */
    },
  },
)

Keywords

cache

FAQs

Package last updated on 17 Aug 2022

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