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
7
votes
1 answer

What's the alternative to pandas chain indexing?

I'm taking an online class to learn python and the instructor taught us that chain indexing was not a good idea. However, he failed to tell is the appropriate alternative to use. Suppose I have a Pandas data frame with rows indexed as ['1', '2',…
RosieMB
  • 71
  • 1
  • 5
7
votes
2 answers

Chain dynamic iterable of context managers to a single with statement

I have a bunch of context managers that I want to chain. On the first glance, contextlib.nested looked like a fitting solution. However, this method is flagged as deprecated in the documentation which also states that the latest with statement…
Richard Neumann
  • 2,986
  • 2
  • 25
  • 50
7
votes
3 answers

Understanding javascript promises; stacks and chaining

I've been running into a couple of problems with javascript promises, particularly with stacked chains. Can anyone explain to me the difference (if there is any!) between these different implementations? IMPLEMENTATION 1 var…
Federico
  • 6,388
  • 6
  • 35
  • 43
7
votes
2 answers

How to stop validation on constraint failure in Symfony2

If I have many validators against my entity, can I somehow specify one that it stops the rest if it fails? IE: there's no point checking Permissions if it fails NotBlank. Alternatively, if its not built in, perhaps theres a way to signal the graph…
jhogendorn
  • 5,931
  • 3
  • 26
  • 35
6
votes
3 answers

Javascript chain rule, return specific value instead of [Object object] [x]

The question is at the title, but first please look at this code: function number(a) { return { add: function(b) { result = a + b; return this; }, substract(b) { result = a - b; …
xx3004
  • 760
  • 2
  • 11
  • 20
6
votes
2 answers

how to Moq Fluent interface / chain methods

I'm using the moq framework by Daniel Cazzulino, kzu Version 4.10.1. I want to moq so i can test a particular part of functionality (below is the simplistic version of the Code i could extract) The fluent/chain method so are designed so you can get…
UndeadEmo
  • 433
  • 1
  • 6
  • 15
6
votes
1 answer

how to execute the procedure one after another in oracle sql developer using chains?

I am a beginner to Oracle SQL. I am using Oracle SQL developer tool. I have two procedures called p1 and p2. How to execute the procedures one by one in particular time daily using chains concept which means I should execute p1 first, once it…
vignesh tokyo
  • 93
  • 1
  • 7
6
votes
1 answer

How to disable DefaultSecurityFilterChain in a Spring Boot app?

In my Spring Boot application, I have: @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ... @Override protected void configure(HttpSecurity httpSecurity) throws Exception …
user1408140
  • 639
  • 3
  • 9
  • 20
6
votes
2 answers

Cypher: how to find all the chains of single nodes not repeated?

I want to find ALL the paths starting and ending from/to a specific node. I would like that each node in a path appears only once. For example, in a graph like…
mdalp
  • 77
  • 6
5
votes
2 answers

Grails - Controller chain and model disapearance

I am trying to use the chain feature to call an other method and render a merged model. This is how I call the chain: Controller: emailToNotify, Method: sendEmailConfirmation if (someCommandObject.hasErrors()) chain(controller:…
Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76
5
votes
3 answers

How to simplify chain of predicates in Kotlin

I have a chain of predicate clauses, something like this student?.firstName?.equals("John") ?: false && student?.lastName?.equals("Smith") ?: false && student?.age?.equals(20) ?: false && student?.homeAddress?.equals("45 Boot Terrace") ?: false…
5
votes
2 answers

How to schedule a chain task in celery

I want to run a complex task scheduled by beat. Let us assume the default add/mul tasks are defined. @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): sender.add_periodic_task( crontab(), add.s(2,3) |…
Serge3
  • 53
  • 1
  • 5
5
votes
1 answer

Chain React setState callbacks

I need to load three different json files in an ordered sequence and with a fetch (the reason is i'm using nextjs export and i need those files to be read dynamically, so I fetch them when needed and their content can change even after the…
Andrew P.
  • 160
  • 1
  • 8
5
votes
1 answer

RxJs: How to conditionally chain observable of BehaviorSubject?

I've got an observable data service (UserService) that returns the currently logged in user. I followed this tutorial - https://coryrylan.com/blog/angular-observable-data-services, which describes using a BehaviorSubject to return a default…
Tim Hardy
  • 1,654
  • 1
  • 17
  • 36
5
votes
1 answer

Bluebird Promise Bind Chain

I am using Bluebird for promises and trying to allow chain calling however using .bind() doesnt seem to work. I am getting: TypeError: sample.testFirst(...).testSecond is not a function The first method is called correctly and starts the promise…
Pat841
  • 2,663
  • 4
  • 17
  • 15
1 2
3
37 38