Skip to content

Instantly share code, notes, and snippets.


Arnaud Esteve aesteve

  • Lille
Block or report user

Report or block aesteve

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
public interface RouteDSL {
RouteDSL param(String paramName, Handler<RoutingContext> checker)
default<T> RouteDSL param(String paramName, Function<String, T> checker) {
return param(paramName, ctx -> {
String p = ctx.request().getParam(name);
try {
ctx.put(paramName, checker.apply(p));;
aesteve / HandlerExtension.kt
Created Oct 11, 2016
Extension method in Kotlin to handle a method reference as a Handler
View HandlerExtension.kt
// It's weird it doesn't work ootb since Handler<T> is a functional java interface
// I must have missed something
fun <T> asHandler(handler: (T) -> Unit): Handler<T> =
Handler { event -> handler(event) }
aesteve /
Created Oct 11, 2016
Creating interceptor-like logic just with handlers
public class InterceptorExample extends AbstractVerticle {
public final static String API_PATH = "/api/v1/";
public final static String STATIC_FILES = "/static/";
// ...
private Router router;
public void start(Future<Void> future) {
aesteve / WhatWeCouldDo.groovy
Last active May 24, 2016
AST transform on AsyncResult methods
View WhatWeCouldDo.groovy
// Let's imagin you have such a service
class TodoMongoService {
void fetchById(String todoId, Handler<AsyncResult<Todo>> handler) {
mongo.find(id) { res ->
if(res.succeeded) {
} else {
aesteve / Uh oh
Created May 8, 2016
exception happening on CI only while testing Nubes with 3.3.0-SNAPSHOT
View Uh oh
java.lang.IllegalStateException: Uh oh! Event loop context executing with wrong thread! Expected null got Thread[Test worker,5,main]
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(
at io.vertx.core.impl.ContextImpl.executeFromIO(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.http1xConnected(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.lambda$internalConnect$159(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue$1.lambda$connect$157(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue$1.connect(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.internalConnect(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.createNewConnection(
List<Handler<RoutingContext>> handlers = /* ... */;
handlers.forEach(router.route("/a/b/")::handler); // KO : "You're attaching a handler to a route more than once"
handlers.forEach(handler -> router.route("/a/b").handler(handler)); // works
aesteve / maps.go
Created Jan 20, 2016
Go Map exercise
View maps.go
package main
import (
func WordCount(s string) map[string]int {
count := make(map[string]int)
words := strings.Fields(s)
aesteve / slices.go
Created Jan 20, 2016
Slices (with closure)
View slices.go
package main
import ""
func mult(x, y int) uint8 {
return uint8( x * y )
func mid(x, y int) uint8 {
return uint8( (x + y) / 2 )
aesteve /
Created Jan 19, 2016
Use Future<Void> instead of timers
package com.github.vertx.node.example;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
aesteve /
Last active Jan 18, 2016
What is flux

Flux is an architecture to help client-side application deal with data coming from several endpoints (API endpoints, websockets, user interaction, etc.).

The basic idea is that you're connecting to many endpoints, and when your "connectors" catch a new piece of data, they're dispatching actions (through a dispatcher).

Reducers are listening to these actions. When they catch an event they're interested in (let's say UserReducer catches an USER_DATA_UPDATED event), they "do something" with the action. Most often, they're just storing the data attached to the action somewhere, and returning their new "state". (their state represent a portion of the global store).

Components (views, basically), on the other hand, can be connected to many reducers (or to the whole store). Thanks to a pure function (connect), you'll describe what the component properties will be for a given state of the global store. Let's say your component only needs some users data and not pricing info for instance. You'll c

You can’t perform that action at this time.