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.

Can't import helper functions to use functions from Components or Controllers

See original GitHub issue

It would be really cool to be able to access these functions from my component logic rather than having to write new, redundant helpers.

Can the library be updated to export each of the helper functions so that I can import them like so:

import { ltHelper } from 'ember-truth-helpers/helpers/lt';

would allow me to access functions like ltHelper in my js code?

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
dehuszarcommented, Aug 3, 2017

Primarily, but not exclusively. If I have to recreate the exact functionality of what a helper is doing as a controller or component function, then the helper is no longer DRY, reusable code, but duplicative code.

In the Ember slack channel I asked if Ember allowed for loading helper functions into other modules. @rwjblue answered that it should and recommended that I create a ticket here so we could look into what was happening. So that’s what I did.

If the answer is won't fix, that’s fine.

0reactions
Turbo87commented, Aug 2, 2017

why have a helper at all?

because there is no < operator in Handlebars and helpers are primarily meant to be used in templates

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use a helper function in a controller? - Stack Overflow
I would use a helper in a Controller Component for generalization and using in many controllers.... – Pipo. Oct 8, 2013 at 22:06....
Read more >
Importing Utility Functions in React.js - Pluralsight
Importing Utility Functions in React.js ... Start off by creating the component called BTCDollarConverter which looks like the following:.
Read more >
Not able to call a helper function from a javascript controller in ...
I have implemented an application in which I have two different buttons. As you can see I am calling two different helper methods...
Read more >
Helper Functions - Components - Ember Guides
Helper functions are JavaScript functions that you can call from your template. ... import { helper } from '@ember/component/helper'; function ...
Read more >
apex - I have two helper functions that are the exact same, one ...
So I have many of these, 10 to be exact and three won't execute, they are all the exact same and I feel...
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