Questions tagged [chain]

Use the tag "method-chaining' if referring to the invocation of multiple methods against a single object. Chaining is the general idea of linking many smaller processes together to form a large process.

Method Chaining allows you to run multiple methods against an object on one line of code.

For example in Java the methods setName and setAge are chained:

Person person = new Person();        //instantiate a new person object.
person.setName("Peter").setAge(21);  //set the name, and age of object person.

First the method setName is applied to the object, then setAge.

Each method returns an object, allowing any number of calls to be chained together in a single statement.

493 questions
36
votes
3 answers

How to properly break out of a promise chain?

Based on the question here: jQuery chaining and cascading then's and when's and the accepted answer, I want to break the promise chain at a point but haven't yet found the correct way. There are multiple posts about this, but I am still lost. Taking…
Dennis G
  • 20,757
  • 17
  • 90
  • 129
27
votes
3 answers

What is the use of filter and chain in servlet?

chain.doFilter(req,res); We used this in a servlet program. I want to know what is the use of the method doFilter() in a servlet? Also what is the use of filter and chain concept in Java servlets?
Vinoth Kumar
  • 2,953
  • 7
  • 21
  • 13
25
votes
3 answers

$q promise error callback chains

In the following code snippet error 1 and success 2 will be logged. How can I can I propagate error callbacks being invoked rather than the success callbacks being invoked if the original deferred is rejected. angular.module("Foo",…
Steven Wexler
  • 14,113
  • 7
  • 42
  • 75
22
votes
2 answers

How to make chainable function in JavaScript?

Lets imagine function like this: function foo(x) { x += '+'; return x; } Usage of it would be like: var x, y; x = 'Notepad'; y = foo(x); console.log(y); // Prints 'Notepad+'. I'm looking for a way to create function that's chainable with…
daGrevis
  • 19,600
  • 35
  • 95
  • 134
19
votes
1 answer

Chaining Singles together in RxJava

I am using RxJava in my android app along with Retrofit to make network requests to a server. I am using RxJavaCallAdapterFactory so I can have my retrofit requests return singles. In my code, the retrofit object is named 'api'. The code here works…
Jtvd78
  • 3,855
  • 3
  • 18
  • 21
18
votes
5 answers

Piping (or command chaining) with QProcess

I'm using Qt and bash over it, need to execute something like: bash: cat file | grep string in Qt: QString cmd = "cat file | grep string"; QProcess *process = new…
Konstantin Ivanov
  • 245
  • 1
  • 3
  • 6
17
votes
2 answers

Promises: Execute something regardless of resolve/reject?

Using the Promises design pattern, is it possible to implement the following: var a, promise if promise.resolve a = promise.responsevalue; if promise.reject a = "failed" AFTER resolution/rejection. Not ASYNC!! send a somewhere,…
nikjohn
  • 16,079
  • 9
  • 45
  • 78
14
votes
2 answers

Promise: Ignore Catch and Return to Chain

Is it possible to ignore a catch and return back to the chain? promiseA() // <-- fails with 'missing' reason .then(promiseB) // <-- these are not going to run .then(promiseC) .catch(function(error, ignore){ if(error.type ==…
Adam Halasz
  • 51,803
  • 63
  • 138
  • 208
14
votes
3 answers

How to route a chain of tasks to a specific queue in celery?

When I route a task to a particular queue it works: task.apply_async(queue='beetroot') But if I create a chain: chain = task | task And then I write chain.apply_async(queue='beetroot') It seems to ignore the queue keyword and assigns to the…
mpaf
  • 5,493
  • 4
  • 34
  • 38
13
votes
5 answers

get lhs object name when piping with dplyr

I'd like to have a function that can use pipe operator as exported from dplyr. I am not using magrittr. df %>% my_function How can I get df name? If I try my_function <- function(tbl){print(deparse(substitute(tbl)))} it returns [1] "." while I'd…
13
votes
3 answers

Celery Task Chain and Accessing **kwargs

I have a situation similar to the one outlined here, except that instead of chaining tasks with multiple arguments, I want to chain tasks that return a dictionary with multiple entries. This is -- very loosely and abstractly --- what I'm trying to…
Benjamin White
  • 750
  • 6
  • 23
12
votes
2 answers

attempting to break jQuery promise chain with .then, .fail and .reject

Update: this issue was a result of jQuery 1.7 vs 1.8. Do not ever use promises in 1.7 beacuse they aren't chainable with returning a promise inside a .then. 1.8 looks like they didn't mess it up. http://jsfiddle.net/delvarworld/28TDM/ // make a…
Andy Ray
  • 26,451
  • 11
  • 86
  • 123
11
votes
1 answer

Javascript call Parent constructor in the Child (prototypical inheritance) - How it works?

I know it works, but I don't know why and how. What are the mechanics? // Parent constructor function Parent(name){ this.name = name || "The name property is empty"; } // Child constructor function Child(name){ this.name = name; } //…
KMS
  • 111
  • 1
  • 3
11
votes
2 answers

Grails: How do I forward an entire model from one controller to another?

How do I pass an entire model from one controller to another without using a redirect?
sparkyspider
  • 11,590
  • 8
  • 73
  • 113
10
votes
2 answers

Celery: clean way of revoking the entire chain from within a task

My question is probably pretty basic but still I can't get a solution in the official doc. I have defined a Celery chain inside my Django application, performing a set of tasks dependent from eanch other: chain( tasks.apply_fetching_decision.s(x,…
Alex Gidan
  • 2,332
  • 14
  • 26
1
2 3
32 33