Giter Club home page Giter Club logo

Comments (10)

markwhitfeld avatar markwhitfeld commented on August 18, 2024 2
this.store.dispatch(new UpdateActive(TodoState, { done: true }));

I think that if we start with this then we can always add other convenient ways to express it later.
I would avoid adding anything other than selectors to the EntityState static members for now.
Once something is added it is difficult to take it back ;-)

from entity-state.

odahcam avatar odahcam commented on August 18, 2024 1

I like the first with lowercase.

from entity-state.

markwhitfeld avatar markwhitfeld commented on August 18, 2024 1

I also prefer the first option (with lowercase if it is an action creator).
The second option would make things bit confusing between selectors and actions in the exposed static interface.

First prize though would be of defining actions using new. Something like this:

this.store.dispatch(new UpdateActive(TodoState, { done: true }));

This action could be defined something like this:

export class UpdateActive<T>{
  constructor(private target: Type<EntityState<T>>, public payload: Updater<T>) {
    return <any> generateActionObject('updateActive', target, payload); 
    // This return tricks the constructor into returning something else ;-)
  }
}

from entity-state.

splincode avatar splincode commented on August 18, 2024

@markwhitfeld

seems logical

this.store.dispatch(new TodoState.updateActive({ done: true }));

from entity-state.

JanMalch avatar JanMalch commented on August 18, 2024

Well, thats .. interesting. If something like this is actually possible I could also create those as static classes on the EntityState so something like new TodoState.UpdateActive({ done: true }) could be possible with full type information. (Same issue as 2. that I can't get the type information from static context.)

While making the constructor returns something else makes me feel uncomfortable I think this is the best approach.

from entity-state.

markwhitfeld avatar markwhitfeld commented on August 18, 2024

If it makes you feel less uncomfortable then you could view it as just a mechanism to create a public API to your dynamic action generator 👍 😉

from entity-state.

odahcam avatar odahcam commented on August 18, 2024

Github needs a fire reaction. 🔥 😆

I liked this comment #2 (comment) proposal, it seems to join all the ideas in one. Maybe it needs some work to be more friendly, but I like it.

from entity-state.

JanMalch avatar JanMalch commented on August 18, 2024

@odahcam What do you propose to make it more friendly? Or what do you consider unfriendly?
Every approach that looks somewhat nicer is in a static context and loses all type information.

We could go so far and use a proxy and write something like this.store.dispatch(new RemoveActive in TodoState.API) or even without new 😅 This might also have type info actually.

from entity-state.

odahcam avatar odahcam commented on August 18, 2024

That's actually very interesting hehe, but I don't have any other suggestion I would like stand for at the moment, I'm already good with what we have. With experience we'll know what to improve.

from entity-state.

JanMalch avatar JanMalch commented on August 18, 2024

Closing this as the syntax is set for now.

from entity-state.

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.