Code Monkey home page Code Monkey logo

Comments (4)

Ben-G avatar Ben-G commented on May 30, 2024

Hey @G4BB3R!

The usage of enums is definitely possible, and in many cases it is a better option than using structs. I have used different approaches over time and haven't found a favorite - as so often it depends a lot on your specific use case.

Currently we're suggesting structs by default, because that allows you to conform to StandardActionConvertible, which some time down the road will hopefully provide you with automatic serialization and deserialization of actions.

That's really the main reason we're using structs in the examples right now.

from reswift.

russbishop avatar russbishop commented on May 30, 2024

@G4BB3R I am using this in a project and all my actions are in fact enums; works just fine.

from reswift.

Aleksion avatar Aleksion commented on May 30, 2024

One thing I will look into before we hit v1 is serialization.

I'll look into Action serialization and State serialization. And I'll make sure to check whether I can figure out a way to do it with enums as well.

Personally I love defining Actions as such:

/**
 * And implemented as an enum action
 */
enum CountEnumAction: Action {
    case Increment
    case Decrement
    case Set(Int)
}

@garnett came up with this in ReduxKit before we merged efforts - and I have been using it ever since. And the good thing about the API's being so close is that the exact same thing is possible in ReSwift

@G4BB3R - We're currently focusing on example projects and updated documentation - and I'll make sure the enum actions and its pro's and con's make it in there :)

from reswift.

Ben-G avatar Ben-G commented on May 30, 2024

I don't think any action is required here; so I'll close this issue!

from reswift.

Related Issues (20)

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.