Comments (8)
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.
from ember-truth-helpers.
Can the library be updated to export each of the helper functions so that I can import them like so:
It is already structured this way, the exact import that you pasted should work...
from ember-truth-helpers.
It is not working for me.
I get the following when trying to access ltHelper
in my code:
Uncaught ReferenceError: ltHelper is not defined
at eval (eval at evaluate (:85:21), <anonymous>:1:1)
at Class.<anonymous> (https://0.0.0.0:4200/assets/skyspecs-portal-fe.js:551:7)
at ComputedPropertyPrototype.get (https://0.0.0.0:4200/assets/vendor.js:27102:28)
at Object.get (https://0.0.0.0:4200/assets/vendor.js:32009:19)
at RootPropertyReference.compute (https://0.0.0.0:4200/assets/vendor.js:25107:26)
at RootPropertyReference.value (https://0.0.0.0:4200/assets/vendor.js:24974:45)
at ArrayIterable.iterate (https://0.0.0.0:4200/assets/vendor.js:24730:26)
at IterationArtifacts.isEmpty (https://0.0.0.0:4200/assets/vendor.js:54789:58)
at IterablePresenceReference.value (https://0.0.0.0:4200/assets/vendor.js:59190:36)
at ReferenceCache.initialize (https://0.0.0.0:4200/assets/vendor.js:55366:52)
at ReferenceCache.peek (https://0.0.0.0:4200/assets/vendor.js:55340:29)
I'm using 2.10.
from ember-truth-helpers.
It is not working for me.
This is surprising to me. Can you whip up a demo repo that I can clone and check?
from ember-truth-helpers.
Sure! https://github.com/dehuszar/importTest
(https://github.com/dehuszar/importTest/blob/master/app/components/import-sandbox.js in particular)
Here's what I'm finding. It turns out I can actually console out the function, but if I attempt to access the same var from a breakpoint, it gives me the message above. I should be able to get done what I need knowing that, but now I'm super curious why a console statement right above my breakpoint can access the ltHelper function, but once I'm at the debugger statement, it doesn't work.
from ember-truth-helpers.
@dehuszar the helpers in this addons are actually very simple (e.g. https://github.com/jmurphyau/ember-truth-helpers/blob/master/addon/helpers/lt.js#L9). I'm not sure why you would want to import the lt
helper to run lt([a, b])
if you could just check a < b
🤔
from ember-truth-helpers.
Because there's value in reusability and composability, and Ember helpers can be very useful in this way. I get that lt([a, b]) is a short snippet, but by that logic, why have a helper at all? Just create new comparison tools in all your controllers or components. Voila!
I was just trying to do something, that I thought was doable and it wasn't working as expected.
from ember-truth-helpers.
why have a helper at all?
because there is no <
operator in Handlebars and helpers are primarily meant to be used in templates
from ember-truth-helpers.
Related Issues (20)
- Helper "not" has wrong value when passing PromiseProxy
- not-eq has unknown reexport HOT 1
- Helper is-empty returns false when passing undefined
- Update to ember-cli-babel@7 HOT 2
- `or` doesn't work the same way as `||` in JavaScript HOT 3
- Update `README` to note that `or`, `and` and `xor` **do** short-circuit HOT 2
- Short-circuit Problem With `SafeString` Using `or` (And Maybe Other Helper)
- Ember Global Deprecation Warning HOT 1
- `or` cant be used when or condition value can be `false` HOT 7
- Project maintenance HOT 4
- Typescript conversion HOT 1
- Can't `npm i` master branch to use with `ember-template-imports` HOT 2
- Cut a release? HOT 12
- Incorrect glint return type for `or` helper in 4.0.0-beta.0 HOT 2
- [QUESTION] `ember-source` compat HOT 3
- `and` returns non-boolean value rather than converting it (which breaks default value logic)
- Document usage with glint additionalSpecialForms config HOT 1
- Memory leaks with `and ` and `or` after they were converted to class based helpers HOT 3
- Importing from package root does not work in classic builds + `.gts`
- Show how to use in template imports
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-truth-helpers.