librariesbelong to a shared space among all packages, so each package needs to use its own namespace.
wp-comments(native WordPress comments) or
disqus-comments(Disqus comments) in your Frontity project because the theme is going to access it using the common
commentsnamespace and everything is going to work. In the future, another person could create a third
commentspackage, based on a new service, and as long as it respects the same structure (written in TypeScript), all the themes (even the old ones!) will work perfectly.
source: for example
analytics: for example
notifications: for example
share: for example
router: for example
actionshave a namespace called
theme. It may seem like it is not adding much value because it is the only namespace. Why not write it like this instead?
actions.comments.submitis responsible for sending the content of the fields in the comment form to WordPress.
themepackages that want to submit a comments form can check if there is a package with the
commentsnamespace with an
actions.comments.submitmethod available. If there is, it can be used from any React component in the project to submit comment form data.
frontity.settings.jsto install and configure
disqus-commentspackage might define a different implementation of
actions.comments.submitthat instead of submitting the comment form data to WordPress it would instead submit it to be handled by Disqus.
themehas no idea about what specific implementation of
commentsyou have installed. Everything works and the theme didn't need to change.
analyticsnamespace. All the packages that want to implement analytics need to have these two actions:
actions.analytics.sendPageview: send a pageview to the analytics service.
actions.analytics.sendEvent: send an event to the analytics service.
actions.analytics.sendPageview, is used by packages that implement
router, each time
actions.analytics.sendEvent, is used by the theme when something interesting happens. For example:
analyticspackage that is installed in the Frontity project, no matter which one it is 🎉🎉