heimdallr icon indicating copy to clipboard operation
heimdallr copied to clipboard

Code refactoring

Open edwardyoon opened this issue 5 years ago • 3 comments

A member of Akka team provided great code review. We need to fix them at least.

https://github.com/akka/akka-http/issues/2391#issuecomment-459970316

edwardyoon avatar Mar 13 '19 07:03 edwardyoon

Would really appreciate your efforts to keep open source code updated!

lkaihua avatar Mar 19 '19 21:03 lkaihua

@jrudolph 's first suggestion is:

Try to get rid of mutable state as much as possible. Global mutable state in a singleton object (like ChatRooms) is absolutely forbidden ;)

In the latest version, the singleton ChatRoom still has a mutable variable to maintain the state:

var chatRooms: mutable.Map[Int, ActorRef]

It can be improved by using context.become:

context.become(update(chatRooms))

while update receives the current state as a parameter. (example)

lkaihua avatar Apr 07 '19 13:04 lkaihua

yeah, that's good point.

edwardyoon avatar May 28 '19 07:05 edwardyoon