@@ -177,44 +177,6 @@ class PoTokenWebView private constructor(
177177 }
178178 // endregion
179179
180- // region Handling multiple emitters
181- /* *
182- * Adds the ([identifier], [emitter]) pair to the [poTokenEmitters] list. This makes it so that
183- * multiple poToken requests can be generated invparallel, and the results will be notified to
184- * the right emitters.
185- */
186- private fun addPoTokenEmitter (identifier : String , emitter : SingleEmitter <String >) {
187- synchronized(poTokenEmitters) {
188- poTokenEmitters.add(Pair (identifier, emitter))
189- }
190- }
191-
192- /* *
193- * Extracts and removes from the [poTokenEmitters] list a [SingleEmitter] based on its
194- * [identifier]. The emitter is supposed to be used immediately after to either signal a success
195- * or an error.
196- */
197- private fun popPoTokenEmitter (identifier : String ): SingleEmitter <String >? {
198- return synchronized(poTokenEmitters) {
199- poTokenEmitters.indexOfFirst { it.first == identifier }.takeIf { it >= 0 }?.let {
200- poTokenEmitters.removeAt(it).second
201- }
202- }
203- }
204-
205- /* *
206- * Clears [poTokenEmitters] and returns its previous contents. The emitters are supposed to be
207- * used immediately after to either signal a success or an error.
208- */
209- private fun popAllPoTokenEmitters (): List <Pair <String , SingleEmitter <String >>> {
210- return synchronized(poTokenEmitters) {
211- val result = poTokenEmitters.toList()
212- poTokenEmitters.clear()
213- result
214- }
215- }
216- // endregion
217-
218180 // region Obtaining poTokens
219181 override fun generatePoToken (identifier : String ): Single <String > =
220182 Single .create { emitter ->
@@ -281,6 +243,44 @@ class PoTokenWebView private constructor(
281243 }
282244 // endregion
283245
246+ // region Handling multiple emitters
247+ /* *
248+ * Adds the ([identifier], [emitter]) pair to the [poTokenEmitters] list. This makes it so that
249+ * multiple poToken requests can be generated invparallel, and the results will be notified to
250+ * the right emitters.
251+ */
252+ private fun addPoTokenEmitter (identifier : String , emitter : SingleEmitter <String >) {
253+ synchronized(poTokenEmitters) {
254+ poTokenEmitters.add(Pair (identifier, emitter))
255+ }
256+ }
257+
258+ /* *
259+ * Extracts and removes from the [poTokenEmitters] list a [SingleEmitter] based on its
260+ * [identifier]. The emitter is supposed to be used immediately after to either signal a success
261+ * or an error.
262+ */
263+ private fun popPoTokenEmitter (identifier : String ): SingleEmitter <String >? {
264+ return synchronized(poTokenEmitters) {
265+ poTokenEmitters.indexOfFirst { it.first == identifier }.takeIf { it >= 0 }?.let {
266+ poTokenEmitters.removeAt(it).second
267+ }
268+ }
269+ }
270+
271+ /* *
272+ * Clears [poTokenEmitters] and returns its previous contents. The emitters are supposed to be
273+ * used immediately after to either signal a success or an error.
274+ */
275+ private fun popAllPoTokenEmitters (): List <Pair <String , SingleEmitter <String >>> {
276+ return synchronized(poTokenEmitters) {
277+ val result = poTokenEmitters.toList()
278+ poTokenEmitters.clear()
279+ result
280+ }
281+ }
282+ // endregion
283+
284284 // region Utils
285285 /* *
286286 * Makes a POST request to [url] with the given [data] by setting the correct headers. Calls
0 commit comments