Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
rapidux
Advanced tools
Readme
R{api}dux is a Swiss army knife for dealing with JSON-API in redux
createLoadHandler(resourceType: string, options: object): nextState
Use it for handle success data loading
Options:
const options = {
mapToKey: bool|string, // default: false, map result to custom reducer key
withLoading: bool, // default: true, enable/disable loading params
singular: bool, // default: false, get first value and store it
withReplace: bool, // default: false, replace current values instead of merge it
addToState: object, // default: {}, additional props passed to state
}
Initial state looks like:
state = {
posts: {
isLoaded: false,
isLoading: false,
posts: {}
}
}
const handlers = {
[LOAD_POSTS.SUCCESS]: createLoadHandler('posts')
}
Resulted state looks like:
state = {
posts: {
isLoaded: true,
isLoading: false,
posts: [1]
}
}
Initial state looks like:
state = {
posts: {
isLoadedPostIds: false,
isLoadingPostIds: false,
post: null,
}
}
Handler:
const handlers = {
[LOAD_POSTS.SUCCESS]: createLoadHandler('posts', { mapToKey: 'post', singular: true })
}
Resulted state looks like:
state = {
posts: {
isLoadedPostIds: true,
isLoadingPostIds: false,
postIds: 1,
}
}
createDeleteHandler(stateKey: string, options: object): nextState
Use it for handle delete data.
Action payload should have deletedId
param with singular ID, or deletedIds
with array of IDS
Initial state looks like:
state = {
posts: {
posts: [1, 2]
}
}
Handler:
const handlers = {
[DELETE_POST.SUCCESS]: createDeleteHandler('posts')
}
// action.payload.deletedId = 1
Resulted state looks like:
state = {
posts: {
posts: [2]
}
}
Initial state looks like:
state = {
posts: {
postIds: [1, 2]
}
}
const handlers = {
[DELETE_POST.SUCCESS]: createDeleteHandler('postIds')
}
// action.payload.deletedId = 2
Resulted state looks like:
state = {
posts: {
postIds: [1]
}
}
Initial state looks like:
state = {
posts: {
postIds: [3, 1, 2]
}
}
const handlers = {
[DELETE_POST.SUCCESS]: createDeleteHandler('postIds', {
addToState: {
isDeleted: true
}
})
}
// action.payload.deletedIds = [2, 1]
Resulted state looks like:
state = {
posts: {
postIds: [3],
isDeleted: true
}
}
createRelationAddHandler(type: string, relationName: string): nextState
Use it for add relation to data reducer. Inject it to data.<type>
reducer
Initial state looks like:
state = {
data: {
posts: {
1: {
id: 1,
relationships: {
comments: {
data: [
{
id: 1,
type: 'comments',
},
],
},
},
},
},
}
}
Action looks like:
action = {
type: CREATE_COMMENT.SUCCESS,
payload: {
data: {
comments: {
3: {
id: 3,
relationships: {
post: {
data: {
id: 1,
type: 'posts',
},
},
},
},
},
},
},
}
Handler:
const handlers = {
[CREATE_COMMENT.SUCCESS]: createRelationAddHandler('comments', 'post')
}
Resulted state looks like:
state = {
data: {
posts: {
1: {
id: 1,
relationships: {
comments: {
data: [
{
id: 1,
type: 'comments',
},
{
id: 3,
type: 'comments',
},
],
},
},
},
},
}
}
createRelationDeleteHandler(relationsName: string): nextState
Use it for delete relation from data reducer. Inject it to data.<type>
reducer
Initial state looks like:
state = {
data: {
posts: {
1: {
id: 1,
relationships: {
comments: {
data: [
{
id: 1,
type: 'comments',
},
{
id: 3,
type: 'comments',
},
],
},
},
},
},
}
}
Action looks like:
action = {
type: DELETE_COMMENT.SUCCESS,
payload: {
deletedId: 3,
relationId: 1,
},
}
Handler:
const handlers = {
[DELETE_COMMENT.SUCCESS]: createRelationDeleteHandler('comments')
}
Resulted state looks like:
state = {
data: {
posts: {
1: {
id: 1,
relationships: {
comments: {
data: [
{
id: 1,
type: 'comments',
},
],
},
},
},
},
}
}
Need to add docs & tests
FAQs
Swiss army knife for redux and json api development
The npm package rapidux receives a total of 71 weekly downloads. As such, rapidux popularity was classified as not popular.
We found that rapidux demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.