Questions tagged [function-binding]

Function binding is the practice of taking a generic function and binding it to a specific context. For example taking a function which requires a parameter and creating a bound parameterless function where the parameter is supplied as the context.

66 questions
1
vote
1 answer

JS: Rebound "this" in contextless function call

The function doSomethingElse in this example fails to execute since its this has been rebound to window or global (if in Node) due to a contextless call inside app.populateDatabase. Is there any way to avoid this without referencing app inside every…
user7401478
  • 1,372
  • 1
  • 8
  • 25
1
vote
1 answer

How to cache HTMLElement.focus in a variable?

What is the correct context to store the focus function of an HTMLElement in a variable? I tried, var elem = document.getElementById('elem'); var focus = elem.focus.bind(document); // focus() Illegal Invocation var focus2 = elem.focus.bind(elem); //…
s4san
  • 319
  • 2
  • 9
1
vote
2 answers

context in class method as variable

There is a class as example: var Class = { initialize: function(data){ this.data = data; }, add: function(node){ //add object }, remove: function(node){ //remove object }, findByIndex: function(id){ …
Triple -B
  • 261
  • 2
  • 12
1
vote
1 answer

Why does this MDN example use `undefined` in `.bind(undefined, 37)`?

One of the uses of Function.prototype.bind, according to MDN: The next simplest use of bind() is to make a function with pre-specified initial arguments. These arguments (if any) follow the provided this value and are then inserted at the start of…
Amresh Venugopal
  • 9,299
  • 5
  • 38
  • 52
1
vote
1 answer

Using bind for partial application without affecting the receiver

If I want to partially apply a function I can use bind, but it seems I have to affect the receiver of the function (the first argument to bind). Is this correct? I want to perform partial application using bind without affecting the receiver. …
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
1
vote
1 answer

std::bind with template member function

I have a strange problem that I cannot bind this template member function, all this code compiles: http://ideone.com/wl5hS8 It's a simple code: I have a ExecutionList which should hold callable functions in a std::vector. I can now add functions by…
Gabriel
  • 8,990
  • 6
  • 57
  • 101
1
vote
1 answer

Good approach to using test spies with dynamic function binding

I'm using $.proxy(this, 'methodName') to use methods of my object as event handlers for DOM events. When it comes to testing I'd like to use Jasmine's spyOn to monitor whether the callbacks get fired. However as the listener is attached within my…
wheresrhys
  • 22,558
  • 19
  • 94
  • 162
1
vote
0 answers

MVCObject inconsistency when binding "map" to OverlayView - Google Maps API

I am playing around with custom overlays in Google Maps, especially the OverlayView class. I have after much trouble and debugging concluded that there might be an inconsistency when binding the "map" property of the OverlayView (which derives from…
thomasskov
  • 188
  • 1
  • 7
0
votes
1 answer

Not creating the file when do output binding with Azure functions using python - locally (using Azure storage emulator and Azure storage explorer)

I have a blob container and two folders in it.(inputs,outputs)When an excel file is placed in the input folder I want to trigger the function and after compiling the code I want to place the output excel file in the folder named 'outputs'.I'm using…
0
votes
1 answer

Pickup existing messages using Azure Function App binding with Service Bus

We have an Azure Function app binding setup with Service bus, so that it is triggered when a message goes onto a Queue. However imagine if we disable the Function app, or it is down for whatever reason and some messages backlog onto the Service bus…
0
votes
2 answers

How to use removeEventListener on a handler which was both directly registered and created on the spot by .bind()?

So I called a function with .bind() but later in my code I have to remove that eventListner. EventTarget.addEventListener("click", myFunction.bind(null, arg))
0
votes
1 answer

binding instance method of one class to another class

Consider the following case: class test: def foo(self, o): print(o) @staticmethod def bar(o): print(o) @classmethod def qux(cls, o): print(cls) print(o) def baz(o): print(o) t = test() class A: meth1 = t.bar …
ntjess
  • 570
  • 6
  • 10
0
votes
0 answers

How to INVISIBLE button from recylerview permenantly?Android studio with java

i have 114 items in recylerview , each item have Download button, i want when user click on download then it start downloading and after downloading button shoud be INVISIBLE, i am using button.setVisibility(View.INVISIBLLE) ,but when i close app…
0
votes
0 answers

Effective difference between Function.prototype.call.bind, returning a called function, and function assignment with .call

As far as I can see, the following three approaches accomplish the exact same thing: determining if Element.prototype has native property tagName, irrespective of Element.prototype.hasOwnProperty being locally overwritten: var ownsBind =…
Kithraya
  • 358
  • 2
  • 10
0
votes
1 answer

Typescript: how to check class functions are bound when passing them around

I'm a typescript newbie and I'm just learning about the --noImplicitThis compile flag from the docs, but I have come across a case that doesn't seem to behave in a way I would expect, could someone please help explain how I can correctly type check…
Resonance
  • 3,359
  • 2
  • 16
  • 20