Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

improvement: hook system #56

Closed
aam229 opened this issue Jan 22, 2016 · 1 comment
Closed

improvement: hook system #56

aam229 opened this issue Jan 22, 2016 · 1 comment

Comments

@aam229
Copy link
Contributor

aam229 commented Jan 22, 2016

I think it would be great to have a hook system in order to customize parts of the universal-redux module. This issue is not about which hooks we should provide but rather the architecture for the hook system. I suggest the following:

  • Define an optional hook property in the config file. It should be a path to a file that registers the hooks.
  • The hook.js file would look something like:
import { hooks } from "universal-redux"

export default function registerHooks(register) {
    register(hooks.server.CREATE_ROOT_COMPONENT, myfunction);
    register(hooks.client.CREATE_ROOT_COMPONENT, myotherfunction);
    ...
}
  • Use the hooks in the universal-redux module:
import { CREATE_ROOT_COMPONENT } from "./hooks/server.constants";
import { hook } from "./hooks/hook";

const result = hook(CREATE_ROOT_COMPONENT, (arg1, arg2) => {
  //Default implementation
})(arg1, arg2);

I think it is important to have the default implementation defined in the file where the hook is called for better readability. However, I don't really like my syntax for calling it.

Please let me know what you think. I'm down to create a PR if we can agree on something.

@aam229
Copy link
Contributor Author

aam229 commented Jan 26, 2016

This is part of #59

@aam229 aam229 closed this as completed Jan 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant