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.

[feature] DI in Editors

See original GitHub issue

I’m submitting a feature request

  • Browser: all
  • Language: TypeScript

Current behavior: Library/Custom Editors cannot use Aurelia’s DI. External services, such as the i18n library, must be injected into the users view model and then added to the columnDef.params object just so the grid editor can use that service. Then, the Editors have to perform null checks to ensure the user sets the service on the params object. This means that our Editors using i18n (singleSelectEditor, multipleSelectEditor and dateTimeEditor) are dependent on the user passing in the service.

Expected/desired behavior: Library/Custom Editors support Aurelia’s DI. To implement this we need to loop through the columnDefinitions during the AureliaCustomElement binding and reset the columnDef.editor property with a wrapper such as:

    for (let c of this.columnDefinitions) {
      if (c.editor) {
        c.editor = Factory.of(c.editor).get(this.container)
      }
    }
  • What is the motivation / use case for changing the behavior? I opened this issue for discussion to get your feedback. I have no need for it right now, but I wonder if it will make for a cleaner API instead of using the params property where other values are dumped.

Pros

  1. Users do not have to inject services into their view model 2 Reduce dependencies for the external service from 2 classes to 1 (2 classes being the Editor and the View Model)

Cons

  1. We need to take dependencies on the Aurelia’s Container and Factory resolver in the AureliaCustomElement (unless you could think of a better way)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jmzagorskicommented, Mar 7, 2018

yes I would use the editor property. Nothing should change for the user. But I will work on a PR so we can see it in practice

0reactions
ghiscodingcommented, Mar 23, 2018

Closed by PR #33

Read more comments on GitHub >

github_iconTop Results From Across the Web

Check your document for similarity to online sources
Check your document for similarity to online sources · On the Home tab, choose Editor. · In the Editor pane, find Similarity, and...
Read more >
Advanced Features | Custom Website Layout - Editor X
​Get absolute design control with custom breakpoints. Rearrange your layouts, choose what to show or hide, and tailor the styling at every viewport...
Read more >
Get started editing—ArcGIS Pro | Documentation
On the Edit tab, in the Features group, click Modify · To show tools that perform specific edits, type the name, category, or...
Read more >
Comparison of text editors - Wikipedia
Name Developer Initial release Version Date Acme Rob Pike 1993 Plan 9 and Inferno AkelPad Alexey Kuznetsov Alexander Shengalts 2003 4.9.8 2016‑07... Alphatk Vince Darley 1999...
Read more >
Suggest edits in Google Docs - Computer
Suggest changes to a file · At the top right, click Editing edit and then from the drop-down, select Suggesting add suggestion ....
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