Coder Social home page Coder Social logo

Comments (8)

dehuszar avatar dehuszar commented on June 28, 2024 3

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.

rwjblue avatar rwjblue commented on June 28, 2024

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.

dehuszar avatar dehuszar commented on June 28, 2024

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.

rwjblue avatar rwjblue commented on June 28, 2024

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.

dehuszar avatar dehuszar commented on June 28, 2024

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.

Turbo87 avatar Turbo87 commented on June 28, 2024

@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.

dehuszar avatar dehuszar commented on June 28, 2024

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.

Turbo87 avatar Turbo87 commented on June 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.