GithubHelp home page GithubHelp logo

Comments (3)

mhuebert avatar mhuebert commented on July 17, 2024

just to clarify, is this intended to refer to the execution context for the myRenderer function? (ie. exactly as the js code is typed)

from js-interop.

philoskim avatar philoskim commented on July 17, 2024

Thanks a lot for the fast response and this very intuitive great library!!!

In my guess, this here refers to Handsontable instance.

Refer to an example source: https://handsontable.com/docs/7.1.0/frameworks-wrapper-for-react-custom-renderer-example.html

Anyway, js apply function oftentimes needs this as its argument. I would like to know how I can deal with this situation.

from js-interop.

mhuebert avatar mhuebert commented on July 17, 2024

Maybe something like this:

(defn my-renderer [instance td row col prop value cellProperties]
  (this-as this 
           (-> (j/get-in Handsontable [:renderers :TextRenderer])
               (.call this instance td row col prop value cellProperties))))

The call-in and apply-in in js-interop are for the common case where you want to call a nested function, with this bound to its immediate parent. In your case you need to first use this-as to get the current function's this, and then I'd use .call instead of .apply because we don't have a reliable way of accessing the arguments array.

(There is also js-this and js-arguments but they can't be relied upon generally, they might not do what you expect depending on what the cljs compiler emits for the surrounding code)

from js-interop.

Related Issues (18)

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.