question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic delegation

See original GitHub issue

This was discussed over at tj/node-delegates#14 and we decided to merge the feature then discuss it’s use here. It would replace this with this:

delegate.auto(proto, require('./request'), 'request');
delegate.auto(proto, require('./response'), 'response');

delegate(proto, 'request')
  .method('get')
  .method('is')
  .getter('header')
  .getter('headers')
  .getter('socket');

delegate(proto, 'response')
  .access('body')
  .access('length')
  .access('type');

There are some conflicts, but we can keep the manual delegators for them as shown above. Since __defineGetter__ (and defineSetter) set the configurable property to true, they can be overriden. This means we can automatically delegate most of the properties, and manually delegate what we need to override.

Note that the response manual delegation isn’t necessary since the second delegate.auto overrides the first one, but I think in conflicts it should be manually specified.

One problem I didn’t think of is toJSON and inspect, both of which have implementations in request, response, and context. The context implementation is of course the wanted end result. We could manually define it afterwords, out of the class, although that would a bit hacky.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
tjcommented, Apr 11, 2016

IMO it’s still looking for problems we don’t really have. We’ve probably spent a total of ~1m maintaining that list

1reaction
fengmk2commented, Apr 12, 2016

It’s not conflicts, and the list can tell me which property is request or response. If change to auto, it will become very conflicts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto delegation - Adobe Support
Agreements sent to you can be automatically delegated (assuming the sender allows delegation). By entering an email value into the Auto ...
Read more >
Automatic delegation - No Magic Documentation
In the SysML Internal Block Diagram, the automatic delegation functionality. Creates a connector from the port to the nearest border.
Read more >
Automatic delegation - YouTube
Automatically delegate documents whenever certain conditions apply.Continia Document Capture version 6.50.
Read more >
Automatic Delegation For Java - C2 wiki
Automatic Delegation For Java. It would be very helpful if Java had a syntax to explicitly specify delegation, something in the lines of:....
Read more >
Auto Delegation and selection of delegates | SAP Blogs
Auto Delegation and selection of delegates · Delegator (for whom you need delegation) · Start Date (Date when you want to start delegation)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found