Михаил Капелько 10 months ago
parent
commit
0309ab67b4
2 changed files with 38 additions and 10 deletions
  1. +9
    -5
      Modules/MeetupIdX/src/MeetupId.SectionBus.swift
  2. +29
    -5
      Modules/MeetupIdX/src/MeetupId.Shoulds.swift

+ 9
- 5
Modules/MeetupIdX/src/MeetupId.SectionBus.swift View File

@@ -8,12 +8,16 @@ extension MeetupId {
_ world: World _ world: World
) { ) {
service.any.append(contentsOf: [ service.any.append(contentsOf: [
Bus.Debounce(shouldResetText, 0.2, K.M, K.textApp),
Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
Bus.Sync(shouldResetLoading, K.M, K.isLoading),
//Bus.Debounce(shouldResetText, 0.2, K.M, K.textApp),
Bus.Debounce(shouldManyResetText, 0.2, K.M, K.textApp),
//Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
Bus.Delay(shouldManyFinishLoading, 5, K.M, K.finishLoading),
//Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
Bus.Sync(shouldManyJoin, K.M, K.isJoinAvailable),
//Bus.Sync(shouldResetLoading, K.M, K.isLoading),
Bus.Sync(shouldManyResetLoading, K.M, K.isLoading),


Bus.Debounce(shouldManyResetText, 0.2, K.M, K.testTextApp),
Bus.Debounce(shouldManyTestResetText, 0.2, K.M, K.testTextApp),
]) ])
} }
} }


+ 29
- 5
Modules/MeetupIdX/src/MeetupId.Shoulds.swift View File

@@ -26,6 +26,7 @@ public extension MeetupId {
return nil return nil
} }


/*
static func shouldFinishLoading(_ c: MeetupIdContext) -> Bool? { static func shouldFinishLoading(_ c: MeetupIdContext) -> Bool? {
guard guard
c.isLoading.isRecent, c.isLoading.isRecent,
@@ -35,6 +36,7 @@ public extension MeetupId {
} }
return true return true
} }
*/


static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? { static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? {
if if
@@ -54,25 +56,47 @@ public extension MeetupId {
return nil return nil
} }


/*
static func shouldResetText(_ c: MeetupIdContext) -> String? { static func shouldResetText(_ c: MeetupIdContext) -> String? {
guard c.textUI.isRecent else { return nil } guard c.textUI.isRecent else { return nil }
return formatId(c.textUI.value) return formatId(c.textUI.value)
} }
*/


// MARK: - Many // MARK: - Many
static func shouldManyFinishLoading(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
guard !c.isLoading.keys.isEmpty else { return nil }
var keys = Set<String>()
var d = [String: Bool]()
for id in c.isLoading.keys {
if
let isLoading = c.isLoading.dict[id],
isLoading
{
keys.insert(id)
}
}
return MPAK.Many(keys, d)
}


static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? { static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
/**/print("ИГР MeetupIS.shouldMRT-1")
guard !c.textUI.keys.isEmpty else { return nil }
var d = [String: String]()
for id in c.textUI.keys {
let text = c.textUI.dict[id] ?? ""
d[id] = formatId(text)
}
return MPAK.Many(c.textUI.keys, d)
}

static func shouldManyTestResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
guard !c.testTextUI.keys.isEmpty else { return nil } guard !c.testTextUI.keys.isEmpty else { return nil }
/**/print("ИГР MeetupIS.shouldMRT-2")
var d = [String: String]() var d = [String: String]()
for id in c.testTextUI.keys { for id in c.testTextUI.keys {
let text = c.testTextUI.dict[id] ?? "" let text = c.testTextUI.dict[id] ?? ""
d[id] = formatId(text) d[id] = formatId(text)
} }
let r = MPAK.Many(c.testTextUI.keys, d)
/**/print("ИГР MeetupIS.shouldMRT-3 r: '\(r)'")
return r
return MPAK.Many(c.testTextUI.keys, d)
} }


} }

Loading…
Cancel
Save