Skip to content

Commit beb88dc

Browse files
committed
fix: address some of the review comments
1 parent a4c5872 commit beb88dc

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

common/rnexecutorch/RnExecutorchInstaller.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace rnexecutorch {
99

10+
// This function fetches data from a url address. It is implemented in
11+
// Kotlin/ObjectiveC++ and then bound to this variable. It's done to not handle
12+
// SSL intricacies manually, as it is done automagically in ObjC++/Kotlin.
1013
FetchUrlFunc_t fetchUrlFunc;
1114

1215
jsi::Function RnExecutorchInstaller::loadStyleTransfer(

common/rnexecutorch/jsi/JsiHostObject.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
7777
}
7878

7979
auto function = functions_->find(nameAsString);
80-
if (function != functions_->end()) {
81-
auto dispatcher =
82-
std::bind(function->second, reinterpret_cast<JsiHostObject *>(this),
83-
std::placeholders::_1, std::placeholders::_2,
84-
std::placeholders::_3, std::placeholders::_4);
85-
86-
return hostFunctionCache
87-
.emplace(nameAsString, jsi::Function::createFromHostFunction(
88-
runtime, name, 0, dispatcher))
89-
.first->second.asFunction(runtime);
80+
if (function == functions_->end()) {
81+
return jsi::Value::undefined();
9082
}
9183

92-
return jsi::Value::undefined();
84+
auto dispatcher =
85+
std::bind(function->second, reinterpret_cast<JsiHostObject *>(this),
86+
std::placeholders::_1, std::placeholders::_2,
87+
std::placeholders::_3, std::placeholders::_4);
88+
89+
return hostFunctionCache
90+
.emplace(nameAsString, jsi::Function::createFromHostFunction(
91+
runtime, name, 0, dispatcher))
92+
.first->second.asFunction(runtime);
9393
}
9494

9595
void JsiHostObject::set(jsi::Runtime &runtime, const jsi::PropNameID &name,

src/hooks/computer_vision/useStyleTransfer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { StyleTransferModule } from '../../modules/computer_vision/StyleTransfer
44

55
interface Props {
66
modelSource: ResourceSource;
7-
doNotLoad?: boolean;
7+
preventLoad?: boolean;
88
}
99

10-
export const useStyleTransfer = ({ modelSource, doNotLoad = false }: Props) =>
10+
export const useStyleTransfer = ({ modelSource, preventLoad = false }: Props) =>
1111
useNonStaticModule({
1212
module: StyleTransferModule,
1313
loadArgs: [modelSource],
14-
doNotLoad: doNotLoad,
14+
preventLoad: preventLoad,
1515
});

src/hooks/useNonStaticModule.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export const useNonStaticModule = <
1818
>({
1919
module,
2020
loadArgs,
21-
doNotLoad = false,
21+
preventLoad = false,
2222
}: {
2323
module: ModuleConstructor<M>;
2424
loadArgs: LoadArgs;
25-
doNotLoad?: boolean;
25+
preventLoad?: boolean;
2626
}) => {
2727
const [error, setError] = useState<null | string>(null);
2828
const [isReady, setIsReady] = useState(false);
@@ -31,7 +31,7 @@ export const useNonStaticModule = <
3131
const model = useMemo(() => new module(), [module]);
3232

3333
useEffect(() => {
34-
if (!doNotLoad) {
34+
if (!preventLoad) {
3535
(async () => {
3636
setDownloadProgress(0);
3737
setError(null);
@@ -45,7 +45,7 @@ export const useNonStaticModule = <
4545
})();
4646
}
4747
// eslint-disable-next-line react-hooks/exhaustive-deps
48-
}, [...loadArgs, doNotLoad]);
48+
}, [...loadArgs, preventLoad]);
4949

5050
const forward = async (...input: ForwardArgs): Promise<ForwardReturn> => {
5151
if (!isReady) throw new Error(getError(ETError.ModuleNotLoaded));

0 commit comments

Comments
 (0)