Git Product home page Git Product logo

actus's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar evgenyorekhov avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

actus's Issues

Add logger

It might be not needed if #5 is implemented by adding redux-devtools-extension integration.

Consider improving action API

Current API

The following forms are supported by default:

  1. (value, state) => nextState
  2. (value) => nextState
  3. () => nextState
  4. (value) => (state) => nextState

Pros:

  • form 2 allows to omit state
  • form 3 allows to omit both value and state
  • form 4 works well with Ramda, BUT most of the time you end up needing to read something from state, so you end up writing something like (value, state) => pipe(/* uses value and state */)(state), so the usage of point-free style ends up being impossible, AND this feature can actually be easily added to other forms with the help of the getNextState option

Cons:

  • form 1 looks like a reducer, but the parameters are flipped, which might be confusing for people coming from Redux
  • form 1 doesn't allow to omit value, have to write (ignore, state) => nextState
  • the existence of both form 1 and form 4 make API overloaded
  • hard to extend with new parameters

Proposed APIs

Reducer API

  1. (state, value) => nextState
  2. (state) => nextState
  3. () => nextState

Pros:

  • conventional reducer signature, just like in Redux
  • form 2 allows to omit value
  • form 3 allows to omit both state and value

Cons:

  • form 1 doesn't allow to omit state, have to write (ignore, value) => nextState
  • hard to extend with new parameters

Object API

  1. ({ state, value }) => nextState

Pros:

  • any parameter can be omitted
  • can be easily extended with any number of parameters

Cons:

  • unconventional
  • have to use the names state and value (you can do something like ({ state: users, value: newUser }) => ..., but it's not as convenient as with positional parameters)

Notes:

  • Is value the best name? How about argument? Or a more conventional payload?

Verdict

If actus is going to add support for something like async actions (or effects), the current API will have to be extended, and the best candidate for extension is the Object API.

Make Immer optional

Immer gets in the way even when you're not using it:

TypeError: Cannot perform 'isExtensible' on a proxy that has been revoked

actus-ember - "Must use import to load ES Module" error

Reproducible case: https://github.com/EvgenyOrekhov/super-rentals/tree/must-use-import-to-load-es-module-bug

$ npm start

> [email protected] start C:\super-rentals
> ember serve

Must use import to load ES Module: C:\super-rentals\node_modules\actus-ember\index.js
require() of ES modules is not supported.
require() of C:\super-rentals\node_modules\actus-ember\index.js from C:\super-rentals\node_modules\ember-cli\lib\models\package-info-cache\package-info.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\super-rentals\node_modules\actus-ember\package.json.

Async actions don't get logged

The reason is that subscribers are notified on state changes, not on action calls. This behavior is by design. Not sure what to do here. Perhaps turn the logger plugin into a special internal subscriber that will be notified on action calls, not on state changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.