Skip to content

Conversation

@asinner
Copy link
Contributor

@asinner asinner commented Apr 20, 2017

This is an initial draft a store implementation.

goals:

  • eliminate communication logic from consumer.
  • remove state from component layer

FormDisplay,
} from 'react-dynamic-formbuilder';

import FormBuilder from './FormBuilder';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is IStore too generic?

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants