-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hi @srdanrasic !
Been developing my app, following the Binder Architecture, for a little while now. Works great for most parts. Thanks for coming up with that!
There are still a few things that I am still wondering about and would like to revisit my understanding of those topics. So would appreciate your help.
My biggest struggle is around the passing of services to other services, notably in the "Session" service, as illustrated by the init(client:userService:) of the UserService.
This feels heavy and pretty unwieldy for unit testing services individually (i.e. having to mock an entire service as opposed to just the object we're interested in (i.e. the Room in this case).
So I have tried several times to come up with a different approach and not rely on services as parameters to other services. This implies, in this particular example, that in the AuthenticationSession service the init method of the RoomService be fed just the user we're interested in. Something akin to :
userService = UserService(client)
userService.currentUser.observeNext { user in
roomService = RoomService(client, user: user)
}
or to avoid Cannot assign to property: 'roomService' is a 'let' constant, if we use signals for the services...
userService = UserService(client)
userService
.currentUser
.value()
.map { RoomService(self.client, user: $0) }
.feedNext(into: roomService)
So anytime the authenticated session changes, all the services are recreated with the new user.
This would work great apart from the pesky 'self' captured by a closure before all members were initialized.
Any thoughts on how to make this whole thing with services better?