Questions tagged [chaining]

Chaining is an object-oriented programming technique where methods return the object on which they were called so that another method may be called on the same object, thus forming a method chain.

1000 questions
7
votes
2 answers

JQuery: Chaining vs Callback Functions

Below is the code snippet of JQuery code for Chaining vs Callback Function:- $(selector).animate({ opacity: 1 }).animate({ opacity: 0.5 }); vs $(selector).animate({ opacity: 1}, function() { $(this).animate({ opacity: 0.5 }); }); In what…
technoTarek
  • 3,218
  • 2
  • 21
  • 25
7
votes
1 answer

PHP closure function appended to stdObject and chained

Possible Duplicate: Calling closure assigned to object property directly If I have a class like this: class test{ function one(){ $this->two()->func(); //Since $test is returned, why can I not call func()? } function two(){ $test…
Senica Gonzalez
  • 7,996
  • 16
  • 66
  • 108
7
votes
2 answers

How to mock a complex REST call from the server side?

While working with javascript that uses REST services extensively -- including using vocabs like GET, PUT, POST, DELETES, etc; I have found it hard to mock the server side so front end development can go on independently (of back end). It is also…
Hon Chong Chang
  • 119
  • 1
  • 5
7
votes
2 answers

Is there a way to allow multiple chains to share the same endpoint in Catalyst?

I'm a bit of a Catalyst newbie, and I'm trying to get multiple chains to access the same endpoint ('description' subroutine) e.g: /object/fetch_by_id/*/description /object/fetch_by_name/*/description /object/fetch_by_xref/*/description I don't want…
gawbul
  • 1,207
  • 12
  • 20
7
votes
2 answers

java CompletableFuture.thenCombine returns CompletableFuture of CompletableFuture

I have 3 different methods in my application. All are returning CompletableFuture. I want to execute method 1 and 2 in parallel. On completion of method 1 and 2, I want to trigger method 3 with parameters from method 1 and 2 return…
7
votes
2 answers

Java 8 streams group by 3 fields and aggregate by sum and count produce single line output

I know there a similar questions asked in the forum but none of them seem to be addressing my problem fully. Now I'm very new to Java 8, so please bear with me. I have a list of Products, for example: Input: name category type cost prod1 …
Vuzi
  • 185
  • 2
  • 4
  • 13
7
votes
1 answer

Javascript chaining to wait for pop up window to return

How can I get a chain of functions to execute sequentially, when one of it involves waiting for a popup window? In the authBegin function below, I am popping up a window, which returns to the authBegin function when completed. But the chaining is of…
meow
  • 27,476
  • 33
  • 116
  • 177
7
votes
4 answers

Effects of method chaining

I know the benefits of chaining within PHP but lets say we have this following situation $Mail = new MailClass("mail") ->SetFrom("X") ->SetTo("X") ->SetSubject("X") ->AddRecipient("X") ->AddRecipient("X") …
RobertPitt
  • 56,863
  • 21
  • 114
  • 161
7
votes
1 answer

$q.reject and handling errors in AngularJS chained promises

I'm having trouble understanding a basic concept of error handling with chaining promises. In order to learn the rules, I have written a simple example, guessing what the result will be. But unfortunatly it doesn't behave as I though it will. I have…
Patrice Pistone
  • 73
  • 1
  • 1
  • 4
7
votes
4 answers

How to achieve arbitrary chain on function call in javascript?

I have written code to achieve sum(1)(2) //3 the code looks like: function sum(a) { return function(b) { return a+b } } But I didn't work out the second question, which is how to achieve any arbitrary number of chain function call…
Huibin Zhang
  • 1,072
  • 1
  • 15
  • 30
7
votes
1 answer

Find_by_sql as a Rails scope

r937 from Sitepoint was kind enough to help me figure out the query I need to return correct results from my database. What I need is to be able to use this query as a scope and to be able to chain other scopes onto this one. The query is: SELECT…
rctneil
  • 7,016
  • 10
  • 40
  • 83
7
votes
2 answers

Apply many color filters to the same drawable

I want to apply several color filters in chain to a drawable. Is that possible? Or maybe to create a filter that is the combination of the filters I want to apply. For example, I would like: Drawable d = ...; d.setColorFilter(0x3F000000,…
ilomambo
  • 8,290
  • 12
  • 57
  • 106
7
votes
2 answers

how do you chain commands on several lines in go?

I want to chain commands this way : var cmdGroups = []*commands.CmdGroup { commands.MakeCmdGroup("foo", cmd1, cmd2, cmd3).AddConstraint(cmd1, cmd2).AddConstraint(cmd2, cmd1, cmd3), commands.MakeCmdGroup("bar", cmd1, cmd4).AddConstraint(cmd1,…
Fabien
  • 12,486
  • 9
  • 44
  • 62
7
votes
2 answers

jQuery firing click event without a click

Well, that's kind of what happens. $('.js-custom-dropdown').find('.custom-dropdown-unfolded').toggle(); $('.custom-dropdown-btn, .custom-dropdown-btn-unfolded').keydown(function(event){ if (event.keyCode === 13) { openDropdown($(this)); …
Anton Matyulkov
  • 722
  • 1
  • 7
  • 15
7
votes
2 answers

Coffeescript and jQuery chaining

I'm attempting this in coffeescript: $( element ).mousedown( aFunction ).mouseup( anotherFunction ); I'm trying to work out a way to make use of indents so that something like the following will return what's about: $ element .mousedown…
Ahmed Nuaman
  • 12,662
  • 15
  • 55
  • 87