Questions tagged [dispatch]

Dynamic dispatch (also known as dynamic binding) is the process of mapping a message to a specific sequence of code (method) at runtime. This is done to support the cases where the appropriate method cannot be determined at compile-time (i.e. statically).

Dynamic dispatch is only used for code invocation and not for other binding processes (such as for global variables) and the name is normally only used to describe a language feature where a runtime decision is required to determine which code to invoke.

This Object-Oriented feature allows substituting a particular implementation using the same interface, and therefore it enables polymorphism.

http://en.wikipedia.org/wiki/Dynamic_dispatch

974 questions
3
votes
1 answer

dispatching to main queue always fails

I'm trying to dispatch some code to the main queue via GCD on iOS but even the most simple tests always fail. In the end It boiled down to this: static const int TICK_INTERVAL = 1; #pragma UIApplicationDelegate implementation - (void) doTick { …
2
votes
0 answers

DispatchDraw (Android)

I am overriding the dispatchDraw method in a custom sub view and am wondering if its possible - since the dispatchDraw method is called just prior to drawing - if I can cancel the draw from within this method. The reason I wish to do so is because…
user1118042
  • 163
  • 3
  • 13
2
votes
3 answers

Need to flush the Java EDT ( event dispatch queue )

I have a Java app where many threads are writing to a StyledTextBox rapidly. At some point all the threads are terminated. However, the TextBox continues to receive text for a bit presumably because the dispatch queue was a bit backed up. Is it…
Chimera
  • 5,884
  • 7
  • 49
  • 81
2
votes
1 answer

When might a dispatch table be as good as method_missing in Ruby?

Are there any situations where a dispatch table, implemented as a hash of lambdas, might be as good, if not better, than over-riding Ruby's method_missing? I'm asking because I used this technique today as I'm a comparative newbie with Ruby, but…
Dexygen
  • 12,287
  • 13
  • 80
  • 147
2
votes
1 answer

What is the difference between defining a method with the `where` clause vs omitting it in Julia?

For example: foo(x::Real) = x ^ 2 bar(x::R) where {R<:Real} = x ^ 2 Both seem to have similar performance, which seems to imply that the compiler is creating specialized code for, e.g., Int vs Float64. So is the only difference that in the latter,…
Alec
  • 4,235
  • 1
  • 34
  • 46
2
votes
1 answer

Define a callback using use dispatch within the main component in React

I have a problem that I just can't solve in React. My intention is to define a button callback that will set the value of a state in redux, this callback uses the dispatch function within it with two values containing two different redux states. It…
2
votes
2 answers

Redux doesn't return to my initial state, when logout

After my redux dispatches the logout action, I want to reset to my initial state. I'm using nextjs, and I don't understand why my desired logout reducer in authenticateSlice.js doesn't execute. I was also using a redux-persist to keep my state…
Jc John
  • 1,799
  • 2
  • 34
  • 69
2
votes
1 answer

Automatically generating and chaining mixins for a typescript class

Here is what I have interface BaseEvent { type: string; payload: any; } interface EventEmitter { emit(event: BaseEvent): void; } class BaseClass { constructor(protected eventEmitter: EventEmitter) {} emit(event: BaseEvent) { …
Yggdrasil
  • 1,377
  • 2
  • 13
  • 27
2
votes
0 answers

Lazy loading images with Intersection Observer Api in React by dynamic redux state

I've been trying to create dynamic image elemens which is going to lazy load when images shown on screen. Besides , image src and alt attribute that come from redux state , this state changes with dispatch action. But images just only load first…
2
votes
1 answer

How can I apply globally to Pinia state actions?

How can I apply globally to Pinia state actions. I know how to send data (user) as an attribute to Vuex. But how can I do something similar with Pinia. As well as is there a way do accomplish similar issue with Vue-router globally ? methods:…
user20984971
2
votes
3 answers

Job-based cloud processing solution

I would like to do some cloud processing on a very small cluster of machines (<5). This processing should be based on 'jobs', where jobs are parameterized scripts that run in a certain docker environment. As an example for what a job could be: Run…
Dtag
  • 83
  • 2
  • 12
2
votes
1 answer

How to pass through call of dispatched method and combine with defaults?

I have a generic function foo, a respective default method, and e.g. a formula method. If the default method is dispatched the call to foo.default should be returned as an attribute, whereas if foo.formula was dispatched, X and y arguments should be…
jay.sf
  • 60,139
  • 8
  • 53
  • 110
2
votes
1 answer

Common interface with a wrapper around std::variant or unions

This question is related to Enforcing a common interface with std::variant without inheritance. The difference between that question and this one, is that I wouldn't mind inheritance, I am simply looking for the following structs/classes... struct…
ZeroZ30o
  • 375
  • 2
  • 18
2
votes
2 answers

I can't dispatch delayed job in laravel

The code below doesn't work. I think I have done all things correctly, but somehow I doesn't work. ... MyJob::dispatch($job)->onQueue('processing')->delay(Carbon::now()->addSeconds(30)); ... MyJob.php
PassinateDev
  • 31
  • 1
  • 4
2
votes
0 answers

How can I specify the type of a dispatch function passed as a prop to a child component?

I have a dispatch function called dispatchFetch that I need to pass from the parent component to the child component, and as I am using TypeScript, I need to declare the type in the child component. My parent component contains the following…
SpencePro
  • 31
  • 1
  • 5