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

gives and needs sugar #19

Closed
ahdinosaur opened this issue Feb 12, 2017 · 7 comments
Closed

gives and needs sugar #19

ahdinosaur opened this issue Feb 12, 2017 · 7 comments

Comments

@ahdinosaur
Copy link
Member

ahdinosaur commented Feb 12, 2017

with using nested plugs, sometimes the gives and needs objects can be somewhat annoying.

here's some possible ways to sugar this cat:

  1. give string
exports.gives = 'cats.actions.create'
  1. gives object
exports.gives = {
  'cats.actions.create': true
}
  1. needs object
exports.needs = {
  'cats.actions.create': 'first'
}
  1. gives array?
exports.gives = [
  'cats.actions.create'
]
  1. needs array?!
exports.needs = [
  ['cats.actions.create', 'first']
]

of course these could be just helper modules, but opening a discussion to include here.

/cc @mixmix @pietgeursen @mmckegg

@dominictarr
Copy link
Collaborator

apart from 1, I think these complicate the code too much. better to be simple. it's a few more characters... but lots more logic & tests. I don't think it's worth it, and the discussion is a bikeshed!

but I don't mind if you have a library function that can export a correct depject object, but use whatever syntax you like.

@mmckegg
Copy link

mmckegg commented Feb 12, 2017

Just handling the first case would be fine with me.

@dominictarr
Copy link
Collaborator

dominictarr commented Feb 12, 2017

Oh, actually, I know how I'd put it: this proposal is like an electric can opener, an electric can opener seems like a convienence, because it takes slightly less time to open a can. But, it's a lot more expensive, and how much time do you spend opening cans per day? Also, it's too large to fit in the drawer, so it must live on the bench, there are a lot more ways for it to break down, and it requires a power socket, that could otherwise have been used for something more useful (like blender - which enables you to do something you can't otherwise do).

Electric Can Openers seem like a convience, but they don't really make your life simpler. Persue simplicity, not convienence. Simplicity saves time in the long run, when it matters, when you need to read the code to understand how it really works. When the power goes out. When you have to debug something.

@mmckegg
Copy link

mmckegg commented Feb 13, 2017

exports.create = function(api) {
  return sugar({
     'cats.actions': { create, destroy }
  })
}

yet another way to open the can (by @mixmix + matt)

@ahdinosaur
Copy link
Member Author

published this as a helper module: depnest! 🎉

@mixmix
Copy link
Collaborator

mixmix commented Feb 16, 2017 via email

@dominictarr
Copy link
Collaborator

this seems resolved, closing

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

No branches or pull requests

4 participants