Comments (7)
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.
thank your for your response :/
from blazor-state.
@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.
@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.
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.
Here a screenshot to explain what I mean
from blazor-state.
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)
- Upgrade to MediatR 10
- License collision HOT 5
- What is the reasoning behind the NonNestedClassException? HOT 1
- Question about setting state from outside state class HOT 4
- how to change default log level
- 'Unable to load one or more of the requested types. Method 'Handle' dependents on MediatR v12.0 HOT 5
- Upgrading to 8.0.0 breaks viewer components updating HOT 3
- Tutorial link in readme.md is dead HOT 2
- Failed to fetch dynamically imported module blazor-state.lib.module.js after changing app path HOT 3
- Add History to Routing
- Doubly Nested IActions throw an error.
- Diagnostic analyzer issues in v8.21 HOT 2
- Question - Getting Values At Start Up HOT 1
- Error during Azure pipelines publish HOT 6
- Enabled `ReduxDevTools` throw `NotSupportedException` upon serialization of `CancellationToken` HOT 3
- Analyzer 'BlazorStateAnalyzer.BlazorStateActionAnalyzer' threw an exception of type 'System.TypeInitializationException' HOT 5
- Dispatching updates to ReduxDevTools relies on HOT 1
- Mixed enviroment with plugins who use MediatR HOT 4
- Generics?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazor-state.