Files
react-native/React/Fabric/RCTImageResponseObserverProxy.mm
T
Samuel SuslaandFacebook Github Bot cebc2c9d3e Do not switch queues if not necessary
Summary:
Changelog: [Internal]

Switching queue here is not necessary if we are already on the main queue.

 This is important for Fabric SSTs, otherwise images are missing.

Reviewed By: shergin

Differential Revision: D19907908

fbshipit-source-id: 52e82484afc8e2f591d0c5cc126952990d992e96
2020-02-18 03:40:51 -08:00

53 lines
1.4 KiB
Plaintext

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "RCTImageResponseObserverProxy.h"
#import <React/RCTUtils.h>
#import <react/imagemanager/ImageResponse.h>
#import <react/imagemanager/ImageResponseObserver.h>
#import <react/utils/ManagedObjectWrapper.h>
namespace facebook {
namespace react {
RCTImageResponseObserverProxy::RCTImageResponseObserverProxy(id<RCTImageResponseDelegate> delegate)
: delegate_(delegate)
{
}
void RCTImageResponseObserverProxy::didReceiveImage(ImageResponse const &imageResponse) const
{
UIImage *image = (UIImage *)unwrapManagedObject(imageResponse.getImage());
id<RCTImageResponseDelegate> delegate = delegate_;
auto this_ = this;
RCTExecuteOnMainQueue(^{
[delegate didReceiveImage:image fromObserver:this_];
});
}
void RCTImageResponseObserverProxy::didReceiveProgress(float progress) const
{
auto this_ = this;
id<RCTImageResponseDelegate> delegate = delegate_;
RCTExecuteOnMainQueue(^{
[delegate didReceiveProgress:progress fromObserver:this_];
});
}
void RCTImageResponseObserverProxy::didReceiveFailure() const
{
auto this_ = this;
id<RCTImageResponseDelegate> delegate = delegate_;
RCTExecuteOnMainQueue(^{
[delegate didReceiveFailureFromObserver:this_];
});
}
} // namespace react
} // namespace facebook