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.

561 questions
3
votes
3 answers

How to extend the array with functions that are generators and able to chain them?

How do I extend Array with functions that returns a generator object and be able to chain them? I have tried extending the Array to see if I can chain generator functions. The first call works, but the next chain would not, because it returns a…
3
votes
2 answers

chaining functions with multiple outputs in julia

Julia has good support for chaining functions using |> like x |> foo |> goo However for functions with multiple inputs and multiple outputs, this does not work: julia> f(x, y) = (x+1, y+1) julia> f(1, 2) (2, 3) julia> (1,2) |> f |> f ERROR:…
xiang0x48
  • 621
  • 6
  • 20
3
votes
1 answer

Why the promises chains does not work as expected (chaining tasks)

What are the advantages using the chain with '.then' if it does not work like a expected: new Promise(function(resolve, reject) { // A mock async action using setTimeout setTimeout(function() { resolve(10); }, 3000); }) .then(function(num)…
Biruel Rick
  • 776
  • 1
  • 8
  • 17
3
votes
1 answer

javascript - prototype chain

Please consider such a code: class a { constructor() { this.test = "test from a"; this.testA = "X"; } mimi() { console.log('aaaaaaaa', this.test, this.testA) } } class b extends a { constructor() { …
Kalreg
  • 982
  • 1
  • 13
  • 27
3
votes
2 answers

How to pass state into a dependency chain using dependency injection

I have a number of service classes in a dependency chain (Service A depends on Service B, which depends on Service C etc.); their behaviors are determined by a common parameter (CountryCode), the possible supported country being defined at runtime.…
Faesel Saeed
  • 199
  • 1
  • 15
3
votes
1 answer

Get signing chain from CMSSignedData

How can I get a signing chain from a CMSSignedData (BouncyCastle) to verify it with the signing chain store? Certificate[] storeCertChain = store.getCertificateChain(alias) Isn't there a command or something like this I can get the signing chain…
nolags
  • 633
  • 1
  • 11
  • 30
3
votes
2 answers

Javascript (typescript) Chrome extension, function callback as promises?

for a code like this let anotherFolder='whatever'; let anotherFolder2='whatever'; chrome.bookmarks.create( {title:'whatever2'}, function( parentFolder ) { chrome.bookmarks.move( anotherFolder, {parentId: parentFolder.id}, function() { …
3
votes
1 answer

R markov chain package, is possible to set the coordinates and size of the nodes?

I'm working with R in some biology-behavioural problems, and I have a transition matrix which I want to plot in a certain way. I'm using the markovchain package, which makes easy the visualization. This is a test-code and it's output. >…
3
votes
3 answers

Can a chain be stopped without sending an error message to the console?

With the following code, when I reject the promise, I see the first console.log but I also see the second console.log. This is expected since the rejection only affects the next "then()". The question is, is there any operator equivalent to a…
GWorking
  • 4,011
  • 10
  • 49
  • 90
3
votes
1 answer

Wait execution of a new inner promise

I'm new to this promises world and I got quite a situation I don't know what to do. I have a new promise been called by the result of the first promise. Here is the situation: function asyncCall(object){ return…
Shoyo
  • 349
  • 2
  • 9
3
votes
3 answers

Accessing variables inside a Javascript promise chain

I am using a chained promise in JavaScript (I think). There is a then() function in the chain. I want to access the variable inside the promise, or somehow return the variable via my HTTP response object. var getTitle = function(response) { …
user3320795
  • 523
  • 2
  • 6
  • 17
3
votes
1 answer

RxJava cache network calls

Ok so i'm working on a project and i need to get Json from a server, get the corresponding POJOs, fill some views and end. The problem i am facing is that, i have to nest network calls to get the final data i need. And in order to minimize the…
johnny_crq
  • 4,291
  • 5
  • 39
  • 64
3
votes
2 answers

Haskell chain functions based on separate conditions

Is there an efficient/easy way, when chaining functions applied to one argument, to only apply functions that fulfill their requirements in order to be applied? E.g.: I have 1 argument 'Obj' and 3 functions: func1, func2, func3. Each have their own…
user2999349
  • 859
  • 8
  • 21
3
votes
1 answer

Celery: Structuring sequential tasks and getting the correct status

What is the best way to structure a bunch of sequential tasks using Celery? My code has a bunch of independent tasks (so they can all be immutable signatures), but I want to stop the sequence if one of the tasks throws an exception. I've been…
Paul Choi
  • 31
  • 4
3
votes
1 answer

Unit testing Grails controller chaining

I am unable to figure out how to test for a controller action that does 'chain'. I would like to verify the action. Grails: 2.4.2 Controller: class MyController { def index() { } def doesChain() { chain action: 'index', model: [name: "my…
raaputin
  • 105
  • 4