Add experimental plugin accumulator #42
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently all plugin options are accumulated and passed to the base
Editor
component by higher-order components returned bycreatePlugin
at render time. While this is often useful for plugin uses cases that require their own custom HOC, the options defined by a plugin built withcreatePlugin
are going to be static in a way that doesn't require their accumulation to be done at render time.We're experimenting with moving as many operations as possible to build the full configuration of a plugin outside of the render tree. This should provide some significant render performance increases on each input in an editor with a non-trivial number of plugins.
This change adds the ability to immediately accumulate
Editor
component prop values when passed a configuration object to accumulate onto with an additional__isAccumulator: true
property on the object. Adding this flag should allow us to support this behavior without any breaking changes tocreatePlugin
.The eventually real-world API of this change will handle the
__isAccumulator
flag for an app. Right now internally it looks something like this, wherecreatePluginStack
accumulates a full configuration within its invocation:The result of this will be a single higher-order component wrapping the base
Editor
, rather than one per plugin, with no accumulation done on each render besides any additional options received as props from the app by the higher-order component.This now means plugins are a factory function that takes an object...that returns a higher-order function...that sometimes acts a regular function...that can return an object. My hope is to validate that thinking about plugins more directly as objects in this setup works effectively without making breaking changes. If that's the case, then I'd like to move plugins to be actual objects as much as possible, heavily inspired by slate's plugin organization