Skip to content

Releases: sheinsight/reactive

v0.2.2

12 Sep 07:09
Compare
Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

🐞 问题修复

  • 修复了 store.restore 不能与 ref 一起工作的问题。 - 由 @vikiboss 提交 (116ec)
在 GitHub 查看更改

v0.2.1

10 Sep 09:49
Compare
Choose a tag to compare

   🐞 Bug Fixes

    View changes on GitHub

🐞 问题修复

查看 GitHub 上的变更

v0.2.0

28 Aug 07:09
Compare
Choose a tag to compare

Introducing Enhancers

Reactive is designed to be framework-agnostic, and to adapt to a variety of functional scenarios, Reactive introduces the concept of Enhancer. The internal differences in functionality between Vanilla and React are actually implemented by applying different enhancers.

For convenience and alignment with the original API, Reactive has built-in some enhancers and also provides some enhancer APIs, allowing users to enhance the functionality of stores. If needed, users can also write their own enhancers to expand the functionality of their stores.

See Enhancer for more details.

   🚀 Features

  • Add snapshot to get snapshot  -  by @vikiboss (99ab6)
  • Add useReactive React Hook from @shined/react-use  -  by @vikiboss (24b9d)
  • Add createSingleLoading export from sub module path  -  by @vikiboss (7a8e6)
  • Deprecated getSnapshot, create from vanilla, SubscribeCallback, use snapshot, createVanilla, SubscribeListener instead  -  by @vikiboss (912aa)

   🧩 Enhancers

    View changes on GitHub

引入增强器(Enhancers)

Reactive 设计为框架无关,以适应各种功能场景,引入了 增强器(Enhancer)的概念。Vanilla 与 React 之间的内部功能差异实际上是通过应用不同的增强器来实现的。

为了方便和与原始 API 保持一致,Reactive 内置了一些增强器,并且提供了一些增强器 API,允许用户增强 stores 的功能。如果需要,用户还可以编写自己的增强器来扩展其 stores 的功能。

详情请见 增强器(Enhancer)

🚀 功能特性

  • 新增 snapshot 用于获取快照  -  由 @vikiboss 提交 (99ab6)
  • @shined/react-use 中新增 useReactive React Hook  -  由 @vikiboss 提交 (24b9d)
  • 新增从子模块路径导出的 createSingleLoading  -  由 @vikiboss 提交 (7a8e6)
  • 废弃 getSnapshot, create (vanilla 版本), SubscribeCallback,请改用 snapshot, createVanilla, SubscribeListener  -  由 @vikiboss 提交 (912aa)

🧩 增强器

在 GitHub 上查看更改

v0.1.4

30 Jul 06:41
Compare
Choose a tag to compare

   🚀 Features

   🐞 Bug Fixes

   🏎 Performance

    View changes on GitHub

v0.1.3

23 May 07:35
Compare
Choose a tag to compare

v0.1.3 Release Notes

feat: add CommonJS outputs via tsup
fix: ignore devtools in production mode
chore: mark react as optional peerDependencies
chore: upgrade use-sync-external-store to ^1.2.2

Full Changelog: v0.1.2...v0.1.3

v0.1.3-alpha.0

16 May 09:18
Compare
Choose a tag to compare

v0.1.3-alpha.0 Release Notes

feat: add CommonJS outputs via tsup.
chore: mark react as optional peerDependencies
chore: upgrade use-sync-external-store to ^1.2.2

Full Changelog: v0.1.2...v0.1.3-alpha.0

v0.1.2

12 Mar 02:36
83ba319
Compare
Choose a tag to compare

v0.1.2 Release Notes

fix: fix useSnapshot arguments bug.
chore: optimize TypeScript types exports.
chore: optimize unit tests.

Full Changelog: v0.1.1...v0.1.2

v0.1.1

02 Mar 08:31
2f92ff6
Compare
Choose a tag to compare

v0.1.1 Release Notes

chore: Enhance TypeScript types for existing functions.
chore: Export essential TypeScript types for external reference.

Full Changelog: v0.1.0...v0.1.1

v0.1.0

29 Feb 09:55
2f7e49c
Compare
Choose a tag to compare

v0.1.0 Release Notes

We're excited to announce the release of v0.1.0! This version brings a range of breaking changes, new features, and enhancements that improve the library's performance, scalability, and developer experience. Here's what's new:

Breaking Changes

  • Snapshots: Symbol properties have been removed and Object.freeze has been swapped with Object.preventExtensions to tackle immutability issues.
  • TypeScript: The release package no longer includes hack-remove-readonly.d.ts, making for more consistent TypeScript definitions.
  • DevTools: We've deprecated the devtool option in favor of a new, feature-rich devtools function for a better debugging interface.
// in global type file, such as `global.d.ts` or `typings.d.ts`
- /// <reference path="@shined/reactive/hack-remove-readonly.d.ts" />
import { create, devtools } from '@shined/reactive'

// remove `devtool` option in create function
const store = create({ name: 'Pikachu' })

// now you should use `devtools` function to enable DevTools
devtools(store, { name: 'pikachu' })

New Features

  • State Selector: Take control of React re-renders with the new selector, which allows for more granular rendering optimization backed by robust TypeScript support.
  • Comparison Function: The introduction of isEqual, a tailor-made comparison function defaulting to shallowEqual, helps in managing state changes efficiently.
  • Utilities: The newly added produce utility acts as an alternative to immer's produce, enhancing state immutability handling.
const App = () => {
  // any change in `store.mutate` will trigger re-render
  const state = store.useSnapshot()

  // only changes in `store.mutate.author` will trigger re-render
  const author = store.useSnapshot((s) => s.author)

  // only changes in `store.mutate.someName` and `store.mutate.someAge` will trigger re-render
  const [name, age] = store.useSnapshot((s) => [s.someName, s.someAge])

  // or use object destructuring, same as above
  const { name, age } = store.useSnapshot((s) => ({
    name: s.someName,
    age: s.someAge,
  }))

  // custom `isEqual` function, default to `shallowEqual`
  const state = store.useSnapshot({
    isEqual: (pre, cur) => Object.is(pre, cur),
  })

  // use `isEqual` function with `selector` as first argument
  // in this case, only changes in `store.mutate.count` that is greater than or equal to 2 will trigger re-render
  const count = store.useSnapshot((s) => s.count, { isEqual: (pre, cur) => cur - pre < 2 })

  return <h1>{name}</h1>
}

Enhancements

  • Dependencies: Development dependencies have been cleaned up for an improved project structure, with key updates to vitest and @testing-library/react.
  • Documentation: We've overhauled our README to serve as the single-point-of-reference for library users.
  • Examples: Our examples are now more intuitive and informative, helping developers understand the library's potential uses cases better.

Internal Improvements

  • Codebase: Restructured for enhanced clarity, the codebase is now more modular.
  • Testing: Test coverage has been expanded with new cases, fortifying the assurance in our library's robustness.
  • Environment: We've upgraded to Node.js version 20.x, ensuring compatibility with the latest performance standards.

Export Changes

  • Adjustments have been made to both root and vanilla exports, including new aliases and direct exports for key functionality, while maintaining that ProxyMap & ProxySet are exported but not yet implemented. see here for full exports changes.

For a complete rundown of changes, experimental features, and bug fixes, be sure to check the associated pull request changelog or code diff.

These updates reflect our commitment to delivering a streamlined and powerful state management solution that meets the needs of modern application development. We hope you enjoy the improvements!

v0.0.19

15 Nov 08:42
68733a4
Compare
Choose a tag to compare

Because proxy-compare has some behavior that doesn't match our expectations, temporary masking relies on contrast logic

proxy-compare#65

reactive#15