hi all! I’m attempting to implement sticky bucketi...
# ask-questions
a
hi all! I’m attempting to implement sticky bucketing on both swift and kotlin SDKs. The function signatures for the three functions in the interface/protocol are not async and do not accept callbacks. This presents problems because our implementation requires fetching the assignments from our API. We’ve already implemented this with the React SDK where the functions are async. Any recommendations?
a
maybe to wrap the call with async {}
🙌 1
a
so just write the function to block and then async-ify it within the caller?
🤔 1
actually I don’t think that would work. The caller is the growthbook SDK
just to further clarify, it seems like this approach will not work. Since the growthbook SDK is expecting a non-
suspend
function (
async
in Swift) in the interface (protocol in Swift), the growthbook SDK will not be able to wait for the results of an async operation.
a
GBStickyBucketServiceImp is an example of implementation of sticky bucket service. If it is stored in file it can be read by using buffered reader. Reader#readText() method is usual method (non-suspend)
a
yes but that’s not our use case. We need cross-platform sticky bucketing which can only be enabled by back-end sticky bucketing. As mentioned, the React SDK provides an async function signature to support this use case. Is there a reason that the mobile SDKs do not?
we’d be happy to open a pr in your repos with this change
a
From the point of view that all SDKs should be the same you are right. Kotlin SDK just doesn't use advantages of asynchronous operations in this place. From SDKs equality point of view it seems like it is not about suspend non-susped but about that the methods should return Deffered
a
my point is actually from the point of view of needing to support my use case. I’m not an expert on Kotlin async primitives but, at the end of the day, I just need a way to perform an API call and have the
StickyBuckeingService
function wait for the response
is there a reason that the mobile SDKs do not support this?
a
to perform an API calls from all of three (getAssignments, saveAssignments, getAllAssignments) ?
or just from some specific?
a
yes, that’s right. The assignments are being stored in our backend
🤔 1
all 3
a
The pull request was created according to the issue
a
thank you!