You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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...
Regarding that concrete example, yes, you are right that RoomService does not necessarily need a dependency on UserService, but it needs a user.
Alternative to your approach would be passing a signal of user so you could do something like RoomService(client, user: userService.currentUser). When doing unit testing it's then easy to mock the inputs by passing a dummy signal: RoomService(testClient, user: Signal(just: testUser))
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 theRoomService
be fed just the user we're interested in. Something akin to :or to avoid
Cannot assign to property: 'roomService' is a 'let' constant
, if we use signals for the services...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?
The text was updated successfully, but these errors were encountered: