Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM] add spec for ImageStore #25101

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Libraries/Image/ImageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
*/
'use strict';

const RCTImageStoreManager = require('../BatchedBridge/NativeModules')
.ImageStoreManager;
import NativeImageStore from './NativeImageStore';

const Platform = require('../Utilities/Platform');

Expand All @@ -31,8 +30,8 @@ class ImageStore {
* @platform ios
*/
static hasImageForTag(uri: string, callback: (hasImage: boolean) => void) {
if (RCTImageStoreManager.hasImageForTag) {
RCTImageStoreManager.hasImageForTag(uri, callback);
if (NativeImageStore.hasImageForTag) {
NativeImageStore.hasImageForTag(uri, callback);
} else {
warnUnimplementedMethod('hasImageForTag');
}
Expand All @@ -47,8 +46,8 @@ class ImageStore {
* @platform ios
*/
static removeImageForTag(uri: string) {
if (RCTImageStoreManager.removeImageForTag) {
RCTImageStoreManager.removeImageForTag(uri);
if (NativeImageStore.removeImageForTag) {
NativeImageStore.removeImageForTag(uri);
} else {
warnUnimplementedMethod('removeImageForTag');
}
Expand All @@ -70,8 +69,8 @@ class ImageStore {
success: (uri: string) => void,
failure: (error: any) => void,
) {
if (RCTImageStoreManager.addImageFromBase64) {
RCTImageStoreManager.addImageFromBase64(
if (NativeImageStore.addImageFromBase64) {
NativeImageStore.addImageFromBase64(
base64ImageData,
success,
failure,
Expand All @@ -97,8 +96,8 @@ class ImageStore {
success: (base64ImageData: string) => void,
failure: (error: any) => void,
) {
if (RCTImageStoreManager.getBase64ForTag) {
RCTImageStoreManager.getBase64ForTag(uri, success, failure);
if (NativeImageStore.getBase64ForTag) {
NativeImageStore.getBase64ForTag(uri, success, failure);
} else {
warnUnimplementedMethod('getBase64ForTag');
}
Expand Down
36 changes: 36 additions & 0 deletions Libraries/Image/NativeImageStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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.
*
* @flow
* @format
*/

'use strict';

import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';

export interface Spec extends TurboModule {
+hasImageForTag: (
uri: string,
callback: (hasImage: boolean) => void,
) => void;
+removeImageForTag: (
uri: string,
) => void;
+addImageFromBase64: (
base64ImageData: string,
succees: (uri: string) => void,
mitulsavani marked this conversation as resolved.
Show resolved Hide resolved
failure: (error: string) => void;
mitulsavani marked this conversation as resolved.
Show resolved Hide resolved
) => void;
+getBase64ForTag: (
uri: string,
succees: (base64ImageData: string) => void,
mitulsavani marked this conversation as resolved.
Show resolved Hide resolved
failure: (error: string) => void,
mitulsavani marked this conversation as resolved.
Show resolved Hide resolved
) => void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('ImageStoringManager');
mitulsavani marked this conversation as resolved.
Show resolved Hide resolved