3

Using PromiseKit, I am trying to set the output of the when block to the local variable allChatRooms

var allChatRooms : [ChatRoom]
var chatRoomIDs : [String:Bool] = ...
 firstly {

        when(resolved: chatRoomIDs.map{fetchChatRoom(id: $0.key)})

    }.then { chatRooms -> Void in

         allChatRooms = chatRooms <-- Error here

    } 

The complier error is:

enter image description here Note: (ChatRoom and KChatRoom are the same)

How can I set the result to the allChatRooms variable?

Entitize
  • 4,553
  • 3
  • 20
  • 28

1 Answers1

2

The solution is simple, I mistyped the when block. Instead, it should be fulfilled instead of resolved

when(fulfilled: chatRoomIDs.map{fetchChatRoom(id: $0.key)})

Entitize
  • 4,553
  • 3
  • 20
  • 28