How to add state properties from component Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag?Can't bind to 'ngModel' since it isn't a known property of 'input'Updating state fields in ngrx reducerNGRX/Store payload type confusionngrx state is undefinedngrx store - Update an array properly.@ngrx actions with multiple payloadsngrx: Router actions and syncing statengrx: Adjusting the properties of a child state to support reusabilityNgrx store does not give previous state on browser back & forward button clickTaking data from model class and work as condition in angular

Did Kevin spill real chili?

Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?

Java 8 stream max() function argument type Comparator vs Comparable

What LEGO pieces have "real-world" functionality?

How do I mention the quality of my school without bragging

Proof involving the spectral radius and the Jordan canonical form

Why one of virtual NICs called bond0?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

What do you call a plan that's an alternative plan in case your initial plan fails?

3 doors, three guards, one stone

What is the musical term for a note that continously plays through a melody?

Sorting numerically

How can I fade player when goes inside or outside of the area?

What happens to sewage if there is no river near by?

Antler Helmet: Can it work?

What causes the vertical darker bands in my photo?

Why is black pepper both grey and black?

Center align columns in table ignoring minus signs?

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Right-skewed distribution with mean equals to mode?

Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?

Should I discuss the type of campaign with my players?

What would be the ideal power source for a cybernetic eye?

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?



How to add state properties from component



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?Can't bind to 'ngModel' since it isn't a known property of 'input'Updating state fields in ngrx reducerNGRX/Store payload type confusionngrx state is undefinedngrx store - Update an array properly.@ngrx actions with multiple payloadsngrx: Router actions and syncing statengrx: Adjusting the properties of a child state to support reusabilityNgrx store does not give previous state on browser back & forward button clickTaking data from model class and work as condition in angular



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm currently working on a project that involves state management for individual components using Angular 7 and NGRX. However, I need to make this implementation scalable, meaning it can be used multiple times while still working independent.



So far I have managed to get my state running and sorted out all action in my reducer, alongside all effects.



Currently I have this in my reducer:



export interface State extends fromRoot.State 
widgets: WidgetState;


//interface for the specific chunk of state for this reducer
export interface WidgetState
dashboardWidgets: Widget[];
secondDashboardWidgets: Widget[];
error: string;


//set the initial state for the properties in the chunk of state
const initialState: WidgetState =
dashboardWidgets: [],
secondDashboardWidgets: [],
error: ''
;

//---- selectors ----//

//createfeatureselector return the specific chunk of State from 'widgets', in this case WidgetState
const getWidgetFeatureState = createFeatureSelector<WidgetState>('widgets');

//so it's callable from the component export default.
//this function gets the createfeatureselector to look in the correct chunk and fetches the desired property from said chunk
export const getDashboardWidgets = createSelector(
getWidgetFeatureState,
state => state.dashboardWidgets
);

export const getError = createSelector(
getWidgetFeatureState,
state => state.error
);

//---- reducers ----//
//creates a copy of the state and adjusts it with the action.payload before changing the state
export function widgetReducer(state = initialState, action: WidgetActions): WidgetState
switch(action.type)
case WidgetActionTypes.DashboardWidgetAdded:
return
...state,
dashboardWidgets: action.payload
;
case WidgetActionTypes.DashboardWidgetsLoadSuccess:
return
...state,
dashboardWidgets: action.payload,
error: ''

case WidgetActionTypes.DashboardWidgetsLoadFail:
return
...state,
dashboardWidgets: [],
error: action.payload

default:
return state;




and in my actions I have the following:



//create an enum for custom actions for easy accessibility
export enum WidgetActionTypes
DashboardWidgetAdded = '[Dashboard] Widget Added',
DashboardWidgetsLoad = '[Dashboard] Load',
DashboardWidgetsLoadSuccess = '[Dashboard] Load Success]',
DashboardWidgetsLoadFail = '[Dashboard] Load Fail'


//create a class to create a new Action of each type listed in the ActionTypes
export class DashboardWidgetAdded implements Action
readonly type = WidgetActionTypes.DashboardWidgetAdded;

constructor(public payload: Widget[])

export class DashboardWidgetsLoad implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoad;

export class DashboardWidgetsLoadSuccess implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadSuccess;

constructor(public payload: Widget[])

export class DashboardWidgetsLoadFail implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadFail;

constructor(public payload: string)


//use the pipe symbol to pipe all actions together in 1 accessible point
export type WidgetActions = DashboardWidgetAdded
| DashboardWidgetsLoad | DashboardWidgetsLoadSuccess | DashboardWidgetsLoadFail;


As you can see, at the moment I'd have to declare a new array in my state for each different use of my dashboard component.



I would like to be able to just declare this new array and all reducer actions from my component, so that I'd have something like:



this.store.dispatch(new widgetActions.CreateNewStateChunkIfNotExists('secondDashboard'));


Is there any way this can be done? Any help would be welcome.










share|improve this question
























  • I have no clear solution for you, but you maybe want to google "ngrx fractal state management" or somehting like this

    – MoxxiManagarm
    Mar 22 at 9:52

















0















I'm currently working on a project that involves state management for individual components using Angular 7 and NGRX. However, I need to make this implementation scalable, meaning it can be used multiple times while still working independent.



So far I have managed to get my state running and sorted out all action in my reducer, alongside all effects.



Currently I have this in my reducer:



export interface State extends fromRoot.State 
widgets: WidgetState;


//interface for the specific chunk of state for this reducer
export interface WidgetState
dashboardWidgets: Widget[];
secondDashboardWidgets: Widget[];
error: string;


//set the initial state for the properties in the chunk of state
const initialState: WidgetState =
dashboardWidgets: [],
secondDashboardWidgets: [],
error: ''
;

//---- selectors ----//

//createfeatureselector return the specific chunk of State from 'widgets', in this case WidgetState
const getWidgetFeatureState = createFeatureSelector<WidgetState>('widgets');

//so it's callable from the component export default.
//this function gets the createfeatureselector to look in the correct chunk and fetches the desired property from said chunk
export const getDashboardWidgets = createSelector(
getWidgetFeatureState,
state => state.dashboardWidgets
);

export const getError = createSelector(
getWidgetFeatureState,
state => state.error
);

//---- reducers ----//
//creates a copy of the state and adjusts it with the action.payload before changing the state
export function widgetReducer(state = initialState, action: WidgetActions): WidgetState
switch(action.type)
case WidgetActionTypes.DashboardWidgetAdded:
return
...state,
dashboardWidgets: action.payload
;
case WidgetActionTypes.DashboardWidgetsLoadSuccess:
return
...state,
dashboardWidgets: action.payload,
error: ''

case WidgetActionTypes.DashboardWidgetsLoadFail:
return
...state,
dashboardWidgets: [],
error: action.payload

default:
return state;




and in my actions I have the following:



//create an enum for custom actions for easy accessibility
export enum WidgetActionTypes
DashboardWidgetAdded = '[Dashboard] Widget Added',
DashboardWidgetsLoad = '[Dashboard] Load',
DashboardWidgetsLoadSuccess = '[Dashboard] Load Success]',
DashboardWidgetsLoadFail = '[Dashboard] Load Fail'


//create a class to create a new Action of each type listed in the ActionTypes
export class DashboardWidgetAdded implements Action
readonly type = WidgetActionTypes.DashboardWidgetAdded;

constructor(public payload: Widget[])

export class DashboardWidgetsLoad implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoad;

export class DashboardWidgetsLoadSuccess implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadSuccess;

constructor(public payload: Widget[])

export class DashboardWidgetsLoadFail implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadFail;

constructor(public payload: string)


//use the pipe symbol to pipe all actions together in 1 accessible point
export type WidgetActions = DashboardWidgetAdded
| DashboardWidgetsLoad | DashboardWidgetsLoadSuccess | DashboardWidgetsLoadFail;


As you can see, at the moment I'd have to declare a new array in my state for each different use of my dashboard component.



I would like to be able to just declare this new array and all reducer actions from my component, so that I'd have something like:



this.store.dispatch(new widgetActions.CreateNewStateChunkIfNotExists('secondDashboard'));


Is there any way this can be done? Any help would be welcome.










share|improve this question
























  • I have no clear solution for you, but you maybe want to google "ngrx fractal state management" or somehting like this

    – MoxxiManagarm
    Mar 22 at 9:52













0












0








0








I'm currently working on a project that involves state management for individual components using Angular 7 and NGRX. However, I need to make this implementation scalable, meaning it can be used multiple times while still working independent.



So far I have managed to get my state running and sorted out all action in my reducer, alongside all effects.



Currently I have this in my reducer:



export interface State extends fromRoot.State 
widgets: WidgetState;


//interface for the specific chunk of state for this reducer
export interface WidgetState
dashboardWidgets: Widget[];
secondDashboardWidgets: Widget[];
error: string;


//set the initial state for the properties in the chunk of state
const initialState: WidgetState =
dashboardWidgets: [],
secondDashboardWidgets: [],
error: ''
;

//---- selectors ----//

//createfeatureselector return the specific chunk of State from 'widgets', in this case WidgetState
const getWidgetFeatureState = createFeatureSelector<WidgetState>('widgets');

//so it's callable from the component export default.
//this function gets the createfeatureselector to look in the correct chunk and fetches the desired property from said chunk
export const getDashboardWidgets = createSelector(
getWidgetFeatureState,
state => state.dashboardWidgets
);

export const getError = createSelector(
getWidgetFeatureState,
state => state.error
);

//---- reducers ----//
//creates a copy of the state and adjusts it with the action.payload before changing the state
export function widgetReducer(state = initialState, action: WidgetActions): WidgetState
switch(action.type)
case WidgetActionTypes.DashboardWidgetAdded:
return
...state,
dashboardWidgets: action.payload
;
case WidgetActionTypes.DashboardWidgetsLoadSuccess:
return
...state,
dashboardWidgets: action.payload,
error: ''

case WidgetActionTypes.DashboardWidgetsLoadFail:
return
...state,
dashboardWidgets: [],
error: action.payload

default:
return state;




and in my actions I have the following:



//create an enum for custom actions for easy accessibility
export enum WidgetActionTypes
DashboardWidgetAdded = '[Dashboard] Widget Added',
DashboardWidgetsLoad = '[Dashboard] Load',
DashboardWidgetsLoadSuccess = '[Dashboard] Load Success]',
DashboardWidgetsLoadFail = '[Dashboard] Load Fail'


//create a class to create a new Action of each type listed in the ActionTypes
export class DashboardWidgetAdded implements Action
readonly type = WidgetActionTypes.DashboardWidgetAdded;

constructor(public payload: Widget[])

export class DashboardWidgetsLoad implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoad;

export class DashboardWidgetsLoadSuccess implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadSuccess;

constructor(public payload: Widget[])

export class DashboardWidgetsLoadFail implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadFail;

constructor(public payload: string)


//use the pipe symbol to pipe all actions together in 1 accessible point
export type WidgetActions = DashboardWidgetAdded
| DashboardWidgetsLoad | DashboardWidgetsLoadSuccess | DashboardWidgetsLoadFail;


As you can see, at the moment I'd have to declare a new array in my state for each different use of my dashboard component.



I would like to be able to just declare this new array and all reducer actions from my component, so that I'd have something like:



this.store.dispatch(new widgetActions.CreateNewStateChunkIfNotExists('secondDashboard'));


Is there any way this can be done? Any help would be welcome.










share|improve this question
















I'm currently working on a project that involves state management for individual components using Angular 7 and NGRX. However, I need to make this implementation scalable, meaning it can be used multiple times while still working independent.



So far I have managed to get my state running and sorted out all action in my reducer, alongside all effects.



Currently I have this in my reducer:



export interface State extends fromRoot.State 
widgets: WidgetState;


//interface for the specific chunk of state for this reducer
export interface WidgetState
dashboardWidgets: Widget[];
secondDashboardWidgets: Widget[];
error: string;


//set the initial state for the properties in the chunk of state
const initialState: WidgetState =
dashboardWidgets: [],
secondDashboardWidgets: [],
error: ''
;

//---- selectors ----//

//createfeatureselector return the specific chunk of State from 'widgets', in this case WidgetState
const getWidgetFeatureState = createFeatureSelector<WidgetState>('widgets');

//so it's callable from the component export default.
//this function gets the createfeatureselector to look in the correct chunk and fetches the desired property from said chunk
export const getDashboardWidgets = createSelector(
getWidgetFeatureState,
state => state.dashboardWidgets
);

export const getError = createSelector(
getWidgetFeatureState,
state => state.error
);

//---- reducers ----//
//creates a copy of the state and adjusts it with the action.payload before changing the state
export function widgetReducer(state = initialState, action: WidgetActions): WidgetState
switch(action.type)
case WidgetActionTypes.DashboardWidgetAdded:
return
...state,
dashboardWidgets: action.payload
;
case WidgetActionTypes.DashboardWidgetsLoadSuccess:
return
...state,
dashboardWidgets: action.payload,
error: ''

case WidgetActionTypes.DashboardWidgetsLoadFail:
return
...state,
dashboardWidgets: [],
error: action.payload

default:
return state;




and in my actions I have the following:



//create an enum for custom actions for easy accessibility
export enum WidgetActionTypes
DashboardWidgetAdded = '[Dashboard] Widget Added',
DashboardWidgetsLoad = '[Dashboard] Load',
DashboardWidgetsLoadSuccess = '[Dashboard] Load Success]',
DashboardWidgetsLoadFail = '[Dashboard] Load Fail'


//create a class to create a new Action of each type listed in the ActionTypes
export class DashboardWidgetAdded implements Action
readonly type = WidgetActionTypes.DashboardWidgetAdded;

constructor(public payload: Widget[])

export class DashboardWidgetsLoad implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoad;

export class DashboardWidgetsLoadSuccess implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadSuccess;

constructor(public payload: Widget[])

export class DashboardWidgetsLoadFail implements Action
readonly type = WidgetActionTypes.DashboardWidgetsLoadFail;

constructor(public payload: string)


//use the pipe symbol to pipe all actions together in 1 accessible point
export type WidgetActions = DashboardWidgetAdded
| DashboardWidgetsLoad | DashboardWidgetsLoadSuccess | DashboardWidgetsLoadFail;


As you can see, at the moment I'd have to declare a new array in my state for each different use of my dashboard component.



I would like to be able to just declare this new array and all reducer actions from my component, so that I'd have something like:



this.store.dispatch(new widgetActions.CreateNewStateChunkIfNotExists('secondDashboard'));


Is there any way this can be done? Any help would be welcome.







angular ngrx ngrx-store






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 8:48







K.Warrens

















asked Mar 22 at 8:28









K.WarrensK.Warrens

207




207












  • I have no clear solution for you, but you maybe want to google "ngrx fractal state management" or somehting like this

    – MoxxiManagarm
    Mar 22 at 9:52

















  • I have no clear solution for you, but you maybe want to google "ngrx fractal state management" or somehting like this

    – MoxxiManagarm
    Mar 22 at 9:52
















I have no clear solution for you, but you maybe want to google "ngrx fractal state management" or somehting like this

– MoxxiManagarm
Mar 22 at 9:52





I have no clear solution for you, but you maybe want to google "ngrx fractal state management" or somehting like this

– MoxxiManagarm
Mar 22 at 9:52












1 Answer
1






active

oldest

votes


















1














I interact with ngrx/store through a wrapper library (that I wrote), ng-app-state, so you may not be able to use this code exactly, but perhaps the general idea will give you inspiration.



When I have done things like this, I have the component that needs its own new slice of the store create and provide a new root level "store object". An equivalent without the wrapper library may be a feature module? It looks something like this:



interface DashboardState 
// all the state needed for a single dashboard
someText: string;


class DashboardStore extends AppStore<DashboardState>
constructor(ngrxStore: Store<any>)
super(ngrxStore, uniqId('dashboard'), makeInitialDashboardState());



@Component(
template: `<input [nasModel]="store('someText')">`,
provides: [DashboardStore],
)
class Dashboard
constructor(public store: DashboardStore)



Then, whenever a dashboard component is on the page it creates its own space in the root store.






share|improve this answer























  • That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

    – K.Warrens
    Mar 24 at 12:05











  • I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

    – K.Warrens
    Mar 25 at 11:23











  • I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

    – Eric Simonton
    Mar 25 at 21:31











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295590%2fhow-to-add-state-properties-from-component%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I interact with ngrx/store through a wrapper library (that I wrote), ng-app-state, so you may not be able to use this code exactly, but perhaps the general idea will give you inspiration.



When I have done things like this, I have the component that needs its own new slice of the store create and provide a new root level "store object". An equivalent without the wrapper library may be a feature module? It looks something like this:



interface DashboardState 
// all the state needed for a single dashboard
someText: string;


class DashboardStore extends AppStore<DashboardState>
constructor(ngrxStore: Store<any>)
super(ngrxStore, uniqId('dashboard'), makeInitialDashboardState());



@Component(
template: `<input [nasModel]="store('someText')">`,
provides: [DashboardStore],
)
class Dashboard
constructor(public store: DashboardStore)



Then, whenever a dashboard component is on the page it creates its own space in the root store.






share|improve this answer























  • That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

    – K.Warrens
    Mar 24 at 12:05











  • I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

    – K.Warrens
    Mar 25 at 11:23











  • I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

    – Eric Simonton
    Mar 25 at 21:31















1














I interact with ngrx/store through a wrapper library (that I wrote), ng-app-state, so you may not be able to use this code exactly, but perhaps the general idea will give you inspiration.



When I have done things like this, I have the component that needs its own new slice of the store create and provide a new root level "store object". An equivalent without the wrapper library may be a feature module? It looks something like this:



interface DashboardState 
// all the state needed for a single dashboard
someText: string;


class DashboardStore extends AppStore<DashboardState>
constructor(ngrxStore: Store<any>)
super(ngrxStore, uniqId('dashboard'), makeInitialDashboardState());



@Component(
template: `<input [nasModel]="store('someText')">`,
provides: [DashboardStore],
)
class Dashboard
constructor(public store: DashboardStore)



Then, whenever a dashboard component is on the page it creates its own space in the root store.






share|improve this answer























  • That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

    – K.Warrens
    Mar 24 at 12:05











  • I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

    – K.Warrens
    Mar 25 at 11:23











  • I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

    – Eric Simonton
    Mar 25 at 21:31













1












1








1







I interact with ngrx/store through a wrapper library (that I wrote), ng-app-state, so you may not be able to use this code exactly, but perhaps the general idea will give you inspiration.



When I have done things like this, I have the component that needs its own new slice of the store create and provide a new root level "store object". An equivalent without the wrapper library may be a feature module? It looks something like this:



interface DashboardState 
// all the state needed for a single dashboard
someText: string;


class DashboardStore extends AppStore<DashboardState>
constructor(ngrxStore: Store<any>)
super(ngrxStore, uniqId('dashboard'), makeInitialDashboardState());



@Component(
template: `<input [nasModel]="store('someText')">`,
provides: [DashboardStore],
)
class Dashboard
constructor(public store: DashboardStore)



Then, whenever a dashboard component is on the page it creates its own space in the root store.






share|improve this answer













I interact with ngrx/store through a wrapper library (that I wrote), ng-app-state, so you may not be able to use this code exactly, but perhaps the general idea will give you inspiration.



When I have done things like this, I have the component that needs its own new slice of the store create and provide a new root level "store object". An equivalent without the wrapper library may be a feature module? It looks something like this:



interface DashboardState 
// all the state needed for a single dashboard
someText: string;


class DashboardStore extends AppStore<DashboardState>
constructor(ngrxStore: Store<any>)
super(ngrxStore, uniqId('dashboard'), makeInitialDashboardState());



@Component(
template: `<input [nasModel]="store('someText')">`,
provides: [DashboardStore],
)
class Dashboard
constructor(public store: DashboardStore)



Then, whenever a dashboard component is on the page it creates its own space in the root store.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 23 at 11:47









Eric SimontonEric Simonton

3,05212140




3,05212140












  • That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

    – K.Warrens
    Mar 24 at 12:05











  • I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

    – K.Warrens
    Mar 25 at 11:23











  • I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

    – Eric Simonton
    Mar 25 at 21:31

















  • That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

    – K.Warrens
    Mar 24 at 12:05











  • I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

    – K.Warrens
    Mar 25 at 11:23











  • I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

    – Eric Simonton
    Mar 25 at 21:31
















That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

– K.Warrens
Mar 24 at 12:05





That sounds like a promising approach. I will be sure to try to see if I can use your example method to fix my issue.

– K.Warrens
Mar 24 at 12:05













I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

– K.Warrens
Mar 25 at 11:23





I had a look at your suggestion, I get the reasoning behind it but I can't seem to figure out what work to do in order for the super(store, 'myId', initialFunction()) to work. What do I put in the root state's constructor and the makeInitialdashboardState() function in order to make it work without wrapper?

– K.Warrens
Mar 25 at 11:23













I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

– Eric Simonton
Mar 25 at 21:31





I'm not sure what exactly your goal is when you say "without wrapper". Or what you're referring to as the "root sate's constructor". However, I can answer 1 part! The makeInitialDashboardState function should return whatever you need to have as the default state for a single dashboard when it is first added.

– Eric Simonton
Mar 25 at 21:31



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295590%2fhow-to-add-state-properties-from-component%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript