What are the correlation between Actor model and Reactive Programming

Could anyone explain the difference/correlation between the Actor model and Reactive programming?

It seems that they are located at different levels of abstraction – one can design the interaction between the components of any distributed system using Actor approach, they would send messages, and inside the actors, write code in reactive style?

this question related to How do Functional Reactive Programming and the Actor model relate to each other?

However, the answers wasn’t clear enough, and my question relates reactive programming in general, not FRP in particular.

How I could save IDs of search results of Reactive Search Pro in DB?

I would like use Reactive Search Pro along with ACF in order to create Questions as CPTs that will have difficulty, grade, rating and other like that fields and I want to be searchable using WP AJAX.

Those search results I would like the Frontend user to be able to gather them and make a composite item that will be an Exam (a set of questions). Using the jquery sortable preferably. So later a user can save/edit them from frontend again using WP AJAX.

My main pain is how I gather the selected items from search and put them inside a sortable in order to make the list and how I submit them to DB so can later can edit them.

Are there any Hooks to use for that? Do you maybe have a guide for achieving something like that?

I am missing a way on how to glue them together the selected search results and storing them to DB via WP AJAX part.

Thanks!

Validacion de formulario async con angular reactive form

Tengo problema, no consigo que se de la validación asíncrona con los reactive form en angular. Consigo que se mantenga la consulta activa al escribir sobre el input y me trae resultados pero no logro mandar el error en el html. Soy nuevo en angular y no se que me estaría faltando en el codigo.

Component.ts

this.registroForm = this.fb.group({   nombre: ["", [Validators.required, Validators.pattern("[a-zA-Z ]*")]],   apellido: ["", [Validators.required, Validators.pattern("[a-zA-Z ]*")]],   username: [     "",     [Validators.required, this.validateEmailNotTaken.bind(this)]   ],   email: ["", [Validators.required, Validators.pattern(this.emailPattern)]],   telefono1: [     "",     [       Validators.required,       Validators.maxLength(10),       Validators.minLength(10),       Validators.pattern("[0-9]*")     ]   ],   condiciones: ["", [Validators.required]] }); 

Mi Funcion de validacion: Va comprobando cada vez que escribo en el input, el servidor me responde de la siguiente manera, cuando existe el nombre en la BD me trae los datos de ese en un array de json, sino un array vacio por eso el data.length. Entonces si es igual a uno deberia mostrar el error. Pero el input escribo cualquier cosa y se coloca en rojo sin mostrar un error especifico (Por la validacion de angular material) y aparte no muestra el error en si de que existe o nombre no disponible.

  validateEmailNotTaken(control: AbstractControl) { let username = {   user: control.value }; return this.authService.buscarUserUsername(username).subscribe(   (data: any) => {     console.log(data.length);     if (data.length === 1) {       return { userNameExists: true };     }   },   err => {     console.log(err);   } ); 

}

MI HTML

<mat-form-field appearance="outline" color="accent">            <mat-label>Usuario</mat-label>            <input formControlName="username" matInput placeholder="Nombre de usuario">            <mat-error *ngIf="registroForm.controls['username'].errors?.required">Este campo es obligatorio            </mat-error>            <mat-error *ngIf="registroForm.controls['username'].errors?.pattern">No es un nombre de usuario valido            </mat-error>            <mat-error *ngIf="registroForm.get('username').errors?.userNameExists">              Nombre de usuario no disponible               </mat-error>           </mat-form-field> 

introducir el código aquí

introducir el código aquí 

Which programming paradigm mixes well with reactive in java? [on hold]

So I have the feeling that one can forget object oriented programming when reactive streams are in use, due to the lack of the async-await syntax (because with the call chaining, the state has to be explicitly passed between blocking and non blocking substeps), nonetheless I also think that dataflow programming alone is not an appropriate basis for abstraction in most applications. E.g. I believe that complex business logic that is not sequential requires different concepts.

Please disprove me if I’m wrong about oop (with an example) or direct me to what is commonly used in parallel with reactive streams. (I guess it’s FP.)

How does the War Caster feat interact with a Hydra’s Reactive Heads trait?

The War Caster feat gives the following property :

When a hostile creature’s movement provokes an opportunity attack from you, you can use your reaction to cast a spell at the creature, rather than making an opportunity attack. The spell must have a casting time of 1 action and must target only that creature.

A Hydra has the following trait :

Reactive Heads. For each head the hydra has beyond one, it gets an extra reaction that can be used only for opportunity attacks.

Let’s say that, for some reason, someone provokes an opportunity attack from a War Caster Hydra (possible by, say, a War Caster Wizard casting Shapechange to become a Hydra)… what happens ?

1) The War Caster Hydra can either use all its heads for opportunity attacks, or only a single head for an eligible spell

2) The War Caster Hydra can use all of its heads for opportunity attacks and/or eligible spells

I suspect that the right answer is 1), but it’s better to verify.

Reactive streams guidelines, patterns and anti-patterns

This is a question about reactive / observable streams, MVI and similar. It’s a set of sub-questions, but I feel they are very coupled, so posting it as one question to capture the similarities.

I’ve been trying to learn concepts around this and I’ve run into several problems while doing that. Here are my observations:

  • Resources (articles, books, videos) are either too low-level (just discussing the API) or too high-level (how to connect two microservices). No discussion about the problems and solutions with using observables within a medium-size app

  • Examples are almost always toy examples with 1-3 streams. No discussion about the problems you face when you have 20 or 100 streams and solutions to those

  • Examples are also almost always static. Streams are pre-wired on startup. No discussion about the problems and solutions related to cases where streams come and go, managing subscriptions and such

  • There are many disagreements and contradictions. Some people suggest using subjects a lot, others suggest never using them. Some people suggest using streams everywhere, some only on the fringes of the system. Some are in favor of a lot of small events and streams, while others prefer coarse-grained structure

Questions arising from the above:

  • Are there medium-sized open-source apps built using reactive streams that I can look at to try to answer these questions myself?

  • Are there any resources that I missed provide answers to some of the questions above?

  • Do you have personal experience with either reactive streams or any other reactive system from which patterns / anti-patterns translate to reactive streams?

  • In general, is there a list of guidelines, patterns and anti-patterns when using reactive streams in medium-sized apps?

Reactive Spring – Proper way to validate another mono

I’m fiddling with Spring webflux and reactive mongo db in a boot app

I’ve been reading but struggling to find the best way to do this logic: I have entry & food services, entry service calls food service to validate that a food exists before saving that entry.

this is my create method in the EntryService

public Mono<Entry> create(Mono<Entry> entry) {     Mono<Food> err = Mono.error(new NotFound());     Mono<Entry> invalidEntry = Mono.error(new IllegalArgumentException());     return entry             .filter(this::isValideEntry)             .switchIfEmpty(invalidEntry)             .flatMap(e -> {                 String foodId = e.getFood().getId();                 return foodService.byId(foodId)                         .switchIfEmpty(err)                         .then(entryRepo.save(e));             }); }  private boolean isValideEntry(Entry e) {     return e.getAmount() > 0         && e.getFood() != null         && e.getFood().getId() != null; } 

food service has a webClient that calls the food service :

public Mono<Food> byId(String id) {     return webClient.get().uri("/{id}", id).retrieve().bodyToMono(Food.class); } 

im not sure if my code is idiomatic in terms of reactive streams in reactor. it seems a bit messy how I’m validating that the food exists and switching back to save the entry.

I’m wondering if there is a better way to rewrite this.

When should I use Reactive web framework

When building a standard web Apis in Java world there is two ways I could do nowadays

  1. Use SpringMVC (Not Reactive)
  2. Use SpringWebFlux (Reactive)

There are few benefits of using Reactive that I can think of

  • It uses less memory resources as there is less thread running (maybe better for a container based deployment)
  • It is better for scenario where your api might need to call other apis and you do not want to think of the concurrency problem (this is can be done in traditional webmvc also but then you need to use completableFuture etc whereas in reactive you let the framework handle it)

There are few disadvantages I can think of when using Reactive

  • Code complexity, as now everything is chained and you need to take care of not blocking the thread and need to be aware of fact that there is no ThreadLocal as such things like logging using MDC is more complicated now
  • Increase in latency as there are fewer threads now

One of the selling point of reactive way of doing things is the backpressure concept but when comes to normal request/response in web apis there is no usage of it as either you process it or you do not there is no process up the chain that will reduce the production of data.

I am not sure if the benefit that I laid down above is worth the complexity for a web apis. I would like to hear thoughts on that. If web apis is not the right place to use reactive where would you think is the right place to use it. Or if reactive way is the way to do it then does not mean there is no place any more for traditional webmvc way of doing things?