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 Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-beta.2

2

package.json
{
"name": "kea",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "Smart front-end architecture",

@@ -5,0 +5,0 @@ "author": "Marius Andra",

@@ -51,2 +51,32 @@ /* global test, expect, beforeEach */

test('listeners work with local action keys', () => {
const { store } = getContext()
let listenerRan = false
const firstLogic = kea({
path: () => ['scenes', 'listeners', 'first'],
actions: () => ({
updateName: name => ({ name })
}),
reducers: ({ actions }) => ({
name: ['chirpy', PropTypes.string, {
updateName: (state, payload) => payload.name
}]
}),
listeners: ({ actions }) => ({
updateName: () => {
listenerRan = true
}
})
})
firstLogic.mount()
firstLogic.actions.updateName('derpy')
expect(firstLogic.values.name).toBe('derpy')
expect(listenerRan).toBe(true)
})
test('sharedListeners work', () => {

@@ -53,0 +83,0 @@ const { store } = getContext()

@@ -14,2 +14,4 @@ import { getContext, setPluginContext, getPluginContext } from '../context'

*/
export const LISTENERS_BREAKPOINT = 'kea-listeners breakpoint broke'
export const isBreakpoint = error => error.message === LISTENERS_BREAKPOINT

@@ -53,6 +55,12 @@ export default {

for (const key of Object.keys(newListeners)) {
let newArray = Array.isArray(newListeners[key]) ? newListeners[key] : [newListeners[key]]
for (const actionKey of Object.keys(newListeners)) {
let newArray = Array.isArray(newListeners[actionKey]) ? newListeners[actionKey] : [newListeners[actionKey]]
let key = actionKey
if (typeof logic.actions[key] !== 'undefined') {
key = logic.actions[key].toString()
}
newArray = newArray.map(l => {
return async function (action) {
return function (action) {
const breakCounter = (fakeLogic.cache.listenerBreakpointCounter[key] || 0) + 1

@@ -63,5 +71,6 @@ fakeLogic.cache.listenerBreakpointCounter[key] = breakCounter

if (fakeLogic.cache.listenerBreakpointCounter[key] !== breakCounter) {
throw new Error('kea-listeners breakpoint broke')
throw new Error(LISTENERS_BREAKPOINT)
}
}
const breakpoint = (ms) => {

@@ -79,8 +88,17 @@ if (typeof ms !== 'undefined') {

try {
response = await l(action.payload, breakpoint, action)
response = l(action.payload, breakpoint, action)
if (response && response.then && typeof response.then === 'function') {
return response.catch(e => {
if (e.message !== LISTENERS_BREAKPOINT) {
throw e
}
})
}
} catch (e) {
if (e.message !== 'kea-listeners breakpoint broke') {
if (e.message !== LISTENERS_BREAKPOINT) {
throw e
}
}
return response

@@ -87,0 +105,0 @@ }

@@ -10,1 +10,2 @@ export { kea, connect } from './kea'

export { addConnection } from './core/shared/connect'
export { isBreakpoint } from './core/listeners'

Sorry, the diff of this file is too big to display

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