Skip to content
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

WIP: Add naive support for action hooks #2344

Closed
wants to merge 1 commit into from

Conversation

davejm
Copy link

@davejm davejm commented May 26, 2019

Summary

Related to #1348. This is just an outline of how hooks might be implemented. I don't anticipate working too much on this as I haven't the time, but maybe this is useful to the discussion.

Heavily inspired by WordPress' 'action hooks'. You register a function to run on a particular hook and can optionally assign it a priority (not implemented). This could be complemented or merged with WordPress' idea of filter hooks. I think the functionality provided by action/filter hooks could provide a lot of possibilities for netlify-cms.

Test plan

WIP

A picture of a cute animal (not mandatory but encouraged)

@netlify
Copy link

netlify bot commented May 26, 2019

Preview proposed changes to the CMS demo site in the link below:

Built with commit 73e355b

https://deploy-preview-2344--cms-demo.netlify.com

@netlify
Copy link

netlify bot commented May 28, 2019

Preview proposed changes to netlifycms.org in the link below:

Built with commit 73e355b

https://deploy-preview-2344--netlify-cms-www.netlify.com

@erquhart
Copy link
Contributor

erquhart commented Jun 4, 2019

This is compelling - I have some lower level thoughts about the API (registerActionHook should accept an object, for example, as that's we're taking most of our reg methods), but I'm more interested in broad strokes discussion of this approach.

@Benaiah @talves @barthc @tomrutgers thoughts?

@talves
Copy link
Collaborator

talves commented Jun 4, 2019

I like the idea of having some type of action Hook in the CMS, but need to think on whether it needs to be a registered Hook or just a listener type event handler.

function hookHandler(event, args) {
  If (event.action === "SOME_ACTION") {
    // Do something
  }
}

const options = { action: 'SOME_ACTION' }
const cmsHook = CMS.addHookListener(hookHandler, options)

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 29, 2019
@stale stale bot removed the wontfix label Oct 29, 2019
@cpjolicoeur
Copy link

Please, what is the status of this?

@stale stale bot removed the status: stale label Oct 29, 2019
@erquhart
Copy link
Contributor

@cpjolicoeur the issue is still something we want to fulfill. This PR is almost a duplicate of your issue as the code is pretty simplistic, almost a POC. Going to close this until we're ready to implement (as it feels mostly like a duplicate issue with a code example), but I would consider the issue not far from top of pile.

@erquhart erquhart closed this Nov 18, 2019
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.

None yet

5 participants