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

kea

Package Overview
Dependencies
Maintainers
1
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kea - npm Package Versions

23
24

3.1.6

Diff

Changelog

Source

3.1.6 - 2023-12-19

  • Increase the amount of supported selectors in a selector's input from 11 to 16.
mariusandra
published 3.1.5 •

Changelog

Source

3.1.5 - 2023-03-16

  • Fix bug with deriving default key from undefined props.
mariusandra
published 3.1.4 •

Changelog

Source

3.1.4 - 2023-01-16

  • Support searching by key in logic.findMounted(123) and logic.isMounted('string key').
  • Adds logic.find(keyOrProps?), which throws if the logic is not mounted.
mariusandra
published 3.1.3 •

Changelog

Source

3.1.3 - 2023-01-16

  • Release with experimental KeaLogicType type builder (experimental only in 3.1.x).
mariusandra
published 3.1.2 •

Changelog

Source

3.1.2 - 2022-12-14

  • Add useAsyncActions hook
mariusandra
published 3.1.1 •

Changelog

Source

3.1.1 - 2022-12-13

  • Add support for asyncActions:
const logic = kea([
  actions({
    fetchUser: (id: number) => ({ id }),
  }),
  listeners({
    fetchUser: async ({ id }, breakpoint) => {
      await breakpoint(100)
      const user = await fetch(`https://example.com/users/${id}`)
      breakpoint()
      return user
    },
  }),
])
const user = await logic.actions.fetchUser(1)

The promise returns whatever is returned in the first listener that listens to this action. Ususally that's the output of the only listener is the same logic that creates the action.

In case you use breakpoints, and the action is called multiple times, all the promises will resolve when the last called action returns.

That means in the case of

const promise1 = logic.actions.fetchUser(1)
const promise2 = logic.actions.fetchUser(1)

Both promises will resolve at the same time. The first dispatch one that breaks will resolve when the second one finishes.

To make this work, each created action now also comes with an ever-increasing dispatchId:

logic.actionCreators.fetchUser(123) ===
  {
    type: 'fetch user (logic)',
    payload: { id: 123 },
    dispatchId: 1,
  }

To disable setting dispatchId and hence support for async actions, call resetContext({ disableAsyncActions: true }).

mariusandra
published 3.1.0 •

Changelog

Source

3.1.0 - 2022-12-13

  • Make logic.props mutable, and store props input immutably in logic.lastProps. This fixes a bug:
const propValues = []
const logic = kea([
  actions({ doStuff: true }),
  listeners(({ props }) => ({
    doStuff: () => {
      propValues.push(props.value)
    },
  })),
])

logic({ value: 0 }).mount()
logic({ value: 1 }).actions.doStuff()
logic({ value: 2 }).actions.doStuff()

Previously propValues would contain [0, 0], but now it contains [1, 2].

mariusandra
published 3.0.4 •

Changelog

Source

3.0.4 - 2022-10-01

  • Support "prop selectors" in selectors. Now p.id is a shorthand for (_, props) => props.id. For example:
const logic = kea([
  props({} as { id: number }),
  selectors({
    duckAndChicken: [(s, p) => [s.duckId, s.chickenId, p.id], (duckId, chickenId, id) => duckId + chickenId + id],
  }),
])
mariusandra
published 3.0.3 •

Changelog

Source

3.0.3 - 2022-09-20

  • Show better errors in production
mariusandra
published 3.0.2 •

Changelog

Source

3.0.2 - 2022-06-19

  • Remove reference to window from hooks.ts
23
24
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