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
12
votes
3 answers

How to chain animation in android to the same view?

I got some text views and I want to make the buzz effect of MSN. My plan is: take the view, let say 10dip to the left, take it back to its start position after that take it 10dip up then back down back left... and so on. My point is, I have some…
Lukap
  • 31,523
  • 64
  • 157
  • 244
12
votes
1 answer

How to run a promise

I know that't very silly, but how to start a promise chain? I have, for example, var p = new Promise(function(resolve,reject) { setTimeout(function() { return resolve("Hi from promise after timeout"); },1000); }); How to run it? It should…
Kasheftin
  • 7,509
  • 11
  • 41
  • 68
12
votes
1 answer

How do I chain groovy's spaceship operator for multilevel sorting?

Groovy has the spaceship operator <=> which provides an easy way to implement comparisons. How can I chain it in a groovier way then the code below? In this example I want to compare the items by price first and then by name if both have the same…
Leonard Brünings
  • 12,408
  • 1
  • 46
  • 66
12
votes
2 answers

jQuery chaining performance

Are these equivalent in term of speed ? $(this).attr("date",date); $(this).attr("date_start",date_start); $(this).attr("heure_start",heure_start); or $(this).attr("date",date).attr("date_start",date_start).attr("heure_start",heure_start); Even if…
commandos
  • 171
  • 1
  • 8
12
votes
5 answers

Haskell: monadic takeWhile?

I have some functions written in C that I call from Haskell. These functions return IO (CInt). Sometimes I want to run all of the functions regardless of what any of them return, and this is easy. For sake of example code, this is the general…
Mark Rushakoff
  • 249,864
  • 45
  • 407
  • 398
11
votes
5 answers

JS ES6 Promise Chaining

I'm trying to learn how to use promises, but am having trouble comprehending the chaining. I assume that with this code, both promises will run. Then when I call test.then() it should know that test has resolved and pass the resolve data to…
Elliot
  • 1,893
  • 4
  • 17
  • 35
11
votes
5 answers

Angular2 - How to chain async service calls (http requests) in a component?

I have a component which first need to call a service that POST something. Then in the same component I want to wait until the POST is done, to call another service which GETs data. How can I make the GET call wait for the POST call to finish? In…
Sojye
  • 175
  • 2
  • 3
  • 9
10
votes
5 answers

ostream chaining, output order

I have a function that takes an ostream reference as an argument, writes some data to the stream, and then returns a reference to that same stream, like so: #include std::ostream& print( std::ostream& os ) { os << " How are you?" <<…
LowTechGeek
  • 431
  • 3
  • 12
10
votes
4 answers

Code Hinting custom functions/objects/constants, and on chaining, commentary in Adobe Dreamweaver CS5

In Dreamweaver CS5 there's something called Code Hinting (let's call it CH for short). CH has a bunch of information about functions, constants and objects built in the core library. When you press CTRL+SPACEBAR or begin structuring a statement…
ShadowScripter
  • 7,314
  • 4
  • 36
  • 54
10
votes
3 answers

Using values from previously chained thenCompose lambdas in Java 8

The Java 8 coding style preferred by my colleagues is chaining asynchronous calls all the way through, e.g. CompletionStage someMethod() { return doSomething().thenCompose(a -> { // ... return b; }).thenCompose(b -> { //…
Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
10
votes
2 answers

Angular2 - Cannot read property 'subscribe' of undefined in nested call

I have looked at a number of resources including this, this and this, but I have not been able to achieve the desired result. All I'm trying to do is authenticate a user (using firebase) and then once authenticated, load up their profile and store…
benscabbia
  • 17,592
  • 13
  • 51
  • 62
10
votes
3 answers

BeanUtils not works for chain setter

e.g. class tester { @Test public void testBeanUtils() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { Stranger stranger = new Stranger(); BeanUtils.setProperty(stranger,"name","wener"); …
wener
  • 7,191
  • 6
  • 54
  • 78
10
votes
1 answer

How do you use underscore's chain method to return the first item in a multidimensional array?

Say I have an array of arrays, and I want to return the first element of each array within the array: array = [[["028A","028B","028C","028D","028E"], ["028F","0290","0291","0292","0293"], ["0294","0295","0296","0297","0298"], …
Chris Matta
  • 3,263
  • 3
  • 35
  • 48
9
votes
5 answers

Python: jQuery-like function chaining?

I couldn't find anything on this subject on Google, so I think I should ask it here: Is it possible to chain functions with Python, like jQuery does? ['my', 'list'].foo1(arg1, arg2).foo2(arg1, arg2).foo3(arg1, arg2) #etc... I am losing a lot of…
Blender
  • 289,723
  • 53
  • 439
  • 496
9
votes
2 answers

How to write this better? Ruby Sequel chaining OR

In SQL it should look like this: SELECT * FROM `categories_description_old` WHERE ((`categories_description` = '') OR (`categories_name` = '') OR (`categories_heading_title` = '')) My (ugly) solution: conditions = [:categories_name,…
ipsum
  • 1,042
  • 7
  • 17
1 2
3
66 67