ReactKit / SwiftState

Elegant state machine for Swift.
MIT License
904 stars 93 forks source link

Arrow pointing the wrong direction for sending events? #54

Closed Danappelxx closed 7 years ago

Danappelxx commented 7 years ago

This issue is a very non-issue but... shouldn't machine <- event be event -> machine? Code is naturally read from left to right (at least, in english code).

The only reason I can think of to not use -> is because it is a reserved Swift operator. Instead, why not reuse the => operator that is already declared and used in the project to describe state transitions?

Danappelxx commented 7 years ago

Actually, something that I just noticed is that machine <- event returns the same machine. Is the intention to allow chains like machine <- event1 <- event2 <- event3? In that case event3 => event2 => event1 => machine does look quite messy...

inamiy commented 7 years ago

Sorry for late response.

<- is used similar way as Golang's Chan, basically means "setter" and used in many other langs/libs. BTW, you can do like machine <- event1 <- event2 <- event3 if you want, and it's intentionally designed as so. (But in any case, it becomes messy...)