You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
709 B

  1. // This function binds the given `handlers` to the `target`.
  2. export function assignHandlers (target, handlers) {
  3. if (!target || !handlers) {
  4. return;
  5. }
  6. // We just bind each handler to the `target`.
  7. const handle = target.handlers = {};
  8. Object.keys(handlers).forEach(
  9. key => handle[key] = handlers[key].bind(target)
  10. );
  11. }
  12. // This function only returns the component if the result of calling
  13. // `test` with `data` is `true`. Useful with funciton binding.
  14. export function conditionalRender (test, data, component) {
  15. return test(data) ? component : null;
  16. }
  17. // This object provides props to make the component not visible.
  18. export const hiddenComponent = { style: { display: 'none' } };