-
Notifications
You must be signed in to change notification settings - Fork 9
Add initial store implementation #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| FormDisplay, | ||
| } from 'react-dynamic-formbuilder'; | ||
|
|
||
| import FormBuilder from './FormBuilder'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consumer must create a Higher Order Component (HOC) from the original FormBuilder and pass in store reference. This means creating separate component file for their HOC
| export interface IStore { | ||
| // subscribe pushes the subscriber into a list and is called | ||
| // via notify() until unsubscribed. | ||
| subscribe(subscriber: ISubscriber): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISubscriber is to not for a single change, all store changes will notify from this Subscriber. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, every state change will notify all the observers.
| return new Store(props); | ||
| } | ||
|
|
||
| export interface IStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is IStore too generic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, the name can always change to whatever we decide
| return new Store(props); | ||
| } | ||
|
|
||
| export interface IStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At beginning, I am considering only put editingContext inside in a bridge or even just a message channel between formbuilder and optionEditor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do that. From my opinion, it would be easier to develop/maintain a general store object that is responsible for handling all shared state between the react-dynamic-formbuilder components and distributing it to them much like Redux
This is an initial draft a store implementation.
goals: