3 ms·
Magnet pattern is purely about making the code you write nicer to look at. (for spray it had more reasons to exist but for akka-http it is purely a usability pr
by doikor 9y ago
Magnet pattern is purely about making the code you write nicer to look at. (for spray it had more reasons to exist but for akka-http it is purely a usability problem)
Basically it allows you to write
def f[T](fMagnet: FMagnet[T]): X => Y
f(t) { x =>
// ...
}
instead of
def f[T](t: T)(implicit tc: TC[T]): X => Y
f(t).apply { x =>
// ...
}
so just about removing one ".apply"
(see https://github.com/akka/akka-http/issues/100 https://github.com/akka/akka-http/issues/100 where i copy pasted the code bits from)
But yeah first time I read up on the magnet pattern it was a wtf moment.