dduan/Just

"You are accessing asynchronous result synchronously"

Opened this issue · 4 comments

Hi i am getting this error and i can't understand why it happens.
Can someone please provide me some feedback about this error and why it happens?

Thanks in advance!
Gal

I'm getting the same error. My code is called within a block operation from an operation queue. This should be all synchronously within the block, shouldn't it?

let operation = BlockOperation {
   let response = Just.get(...)
   guard let content = response.content else { return }
  // do something with content here ...
}

Did somebody already figure it out?

exactly the same problem: [Just] You are accessing asynchronous result synchronously.

any ideas?

            `let blockOperation = BlockOperation {
                let r = Just.post(url, headers: headers, timeout: 5, requestBody: bodyParameters)
                Network.logResult(r, forCallTitled: "FETCH POSTS")
                if r.hasValidHTTPCode() {
                    if let jsonResponse = r.responseJSON() {
                        completion?(jsonResponse)
                   } else {
                       failure?("Empty response",nil)
                   }
               } else {
                   let m = r.messageAndError()
                   failure?(m.message,m.error)
                   return
               }
           }
           Dispatcher.shared.queueOperationBlock(blockOperation)`

I fix it by ygweric@38316be

And a pull request is on the way~
#89

Is there any fix for that issue?
I saw that the referenced PR wasn't merged, and i'm keep getting the error using 0.5.7.

Any help would be appreciated...