Giter VIP home page Giter VIP logo

Comments (7)

aboudoux avatar aboudoux commented on May 26, 2024 1

Indeed, an evolution of the store that would allow obtaining a State by an identifier rather than by a Type would be ideal.

from blazor-state.

akbaramd avatar akbaramd commented on May 26, 2024

thank your for your response :/

from blazor-state.

StevenTCramer avatar StevenTCramer commented on May 26, 2024

@akbaramd I enjoy sarcasm :)

ChatGPT

The question appears to be about using a Material Design Interface (MDI) component in a Blazor application, where multiple instances of a specific state are created within each tab of the interface. The user is seeking guidance on how to manage this scenario effectively.

In Blazor, each component can have its own state, but when dealing with multiple instances of the same component (like tabs in an MDI), managing state becomes more complex. The user might be facing challenges with state synchronization across multiple component instances or isolating state for each instance.

To address this, you could consider the following approaches:

1. **Scoped State**: Implement a state that is scoped to each tab. This means each tab will have its own independent state, preventing interference between tabs.

2. **Centralized State Management**: Use a centralized state management pattern (like BlazorState) to manage the state. This approach allows you to have a single source of truth for your state, and each tab can subscribe to state changes as needed.

3. **Event Handling and Propagation**: Ensure that events that trigger state changes are handled correctly. If a state change in one tab needs to reflect in another, this should be managed through event propagation or shared state management.

4. **State Initialization and Cleanup**: When a new tab is opened, initialize its state correctly. Similarly, when a tab is closed, ensure any cleanup or state deregistration is performed to avoid memory leaks or stale state issues.

5. **Testing**: With multiple states and interactions, it's important to thoroughly test the components. Use your testing framework (like Fixie, which you're familiar with) to write tests that simulate the various interactions and state changes.

In summary, the question is about managing multiple instances of state within an MDI component in a Blazor application. The solution involves considering the scope of the state, centralizing state management, handling events properly, and ensuring correct initialization and cleanup of state in each tab.

from blazor-state.

StevenTCramer avatar StevenTCramer commented on May 26, 2024

@aboudoux Please explain? There is only one State per type. If you want to create a collection of things in that state you can. But there isn't a collection of the States by type. And I do not believe there should be. If you can give me a use case and show me some sample I will be happy to look in to it.

Currently the Type is the identifier.

from blazor-state.

aboudoux avatar aboudoux commented on May 26, 2024

If I have a multi-document application in the form of tabs, and each sub-tab also has sub-tabs, I have no choice but to manage a collection of States within a State and pass each State through my actions.

This works well, except that today I am stuck because I am creating a chat space, and I would like all the corresponding States of all connected users to refresh with each message post.

This can be done quite easily by publishing our action to a multicast Bus, but the problem is that I need to find the concerned State for each user. However, if I have a collection of states within a collection of states, I need a way to find the target State, and I can only do this if each State has a defined identifier (like the chat identifier, for example).

from blazor-state.

aboudoux avatar aboudoux commented on May 26, 2024

image

Here a screenshot to explain what I mean

from blazor-state.

aboudoux avatar aboudoux commented on May 26, 2024

Here, the green tabs are all the same state type, and within each tab, there are sub-states. In the Conversation(s) section, I can have 2 Chats. I want that when I post a message, another user connected to this can see it. While I can easily send the action between users, it's impossible for me to find the instance of the other user's state based solely on the type.

from blazor-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.