Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-zero

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-zero - npm Package Compare versions

Comparing version 4.6.1 to 4.7.0

vue/components/connect.d.ts

4

CHANGELOG.md
# Changelog
### 4.7.0
- Add Vue.js bindings
### 4.6.0

@@ -4,0 +8,0 @@

23

package.json
{
"name": "redux-zero",
"version": "4.6.1",
"version": "4.7.0",
"description": "",

@@ -14,4 +14,3 @@ "main": "dist/redux-zero.js",

"format": "prettier --write --no-semi \"src/**/*.ts\" \"src/**/*.tsx\"",
"check":
"npm run compile && npm run format && npm run lint && npm run test",
"check": "npm run compile && npm run format && npm run lint && npm run test",
"clean": "rimraf dist coverage",

@@ -35,2 +34,3 @@ "prebuild": "npm run check && npm run clean",

"utils",
"vue",
"index.d.ts"

@@ -44,8 +44,16 @@ ],

"jest": {
"moduleFileExtensions": ["ts", "tsx", "js"],
"setupFiles": ["<rootDir>/config/testSetup.js"],
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"setupFiles": [
"<rootDir>/config/testSetup.js"
],
"transform": {
"^.+\\.(ts|tsx)$": "<rootDir>/config/preprocessor.js"
},
"testMatch": ["<rootDir>/src/**/*.spec.(ts|tsx)"]
"testMatch": [
"<rootDir>/src/**/*.spec.(ts|tsx)"
]
},

@@ -73,3 +81,4 @@ "devDependencies": {

"tslint": "^5.7.0",
"typescript": "2.5.3"
"typescript": "2.5.3",
"vue": "2.5.9"
},

@@ -76,0 +85,0 @@ "keywords": [

@@ -23,2 +23,3 @@ <h1 align="center">

- [Example](#example)
- [Async](#async)
- [Middleware](#middleware)

@@ -151,3 +152,52 @@ - [Inspiration](#inspiration)

- [Svelte](https://github.com/concretesolutions/redux-zero/tree/master/examples/svelte/counter)
- [Vue](https://github.com/concretesolutions/redux-zero/tree/master/examples/vue/counter)
## Async
Async actions in Redux Zero are almost as simple as sync ones. Here's an example:
```js
const mapActions = ({ setState }) => ({
getTodos() {
setState({ loading: true });
return client.get("/todos")
.then(payload => ({ payload, loading: false }))
.catch(error => ({ error, loading: false }))
}
});
```
They're still pure functions. You'll need to invoke `setState` if you have a loading status. But at the end, it's the same, just return whatever the updated state that you want.
And here's how easy it is to test this:
```js
describe("todo actions", () => {
let actions, store, listener, unsubscribe;
beforeEach(() => {
store = createStore();
actions = getActions(store);
listener = jest.fn();
unsubscribe = store.subscribe(listener);
});
it("should fetch todos", () => {
nock("http://someapi.com/")
.get("/todos")
.reply(200, { id: 1, title: "test stuff" });
return actions.getTodos().then(() => {
const [LOADING_STATE, SUCCESS_STATE] = listener.mock.calls.map(
([call]) => call
);
expect(LOADING_STATE.loading).toBe(true);
expect(SUCCESS_STATE.payload).toEqual({ id: 1, title: "test stuff" });
expect(SUCCESS_STATE.loading).toBe(false);
});
});
});
```
## Middleware

@@ -154,0 +204,0 @@

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