MCPcopy Create free account
hub / github.com/Snapchat/Valdi / hotReload

Method hotReload

valdi/test/integration/RuntimeTestsUtils.cpp:178–201  ·  view source on GitHub ↗

Replace a resource from another existing resource to test hot reloading.

Source from the content-addressed store, hash-verified

176
177// Replace a resource from another existing resource to test hot reloading.
178Result<Void> RuntimeWrapper::hotReload(const char* sourceResourcePath, const char* destResourcePath) {
179 auto resourceId = Valdi::JavaScriptPathResolver::resolveResourceId(STRING_LITERAL(sourceResourcePath));
180 if (!resourceId) {
181 return resourceId.moveError();
182 }
183
184 auto bundle = runtime->getResourceManager().getBundle(resourceId.value().bundleName);
185
186 auto jsResult = bundle->getJs(resourceId.value().resourcePath);
187 if (!jsResult) {
188 return jsResult.moveError();
189 }
190
191 auto destResourceId = Valdi::JavaScriptPathResolver::resolveResourceId(STRING_LITERAL(destResourcePath));
192 if (!destResourceId) {
193 return destResourceId.moveError();
194 }
195
196 auto jsResource = ResourceId(destResourceId.value().bundleName, destResourceId.value().resourcePath.append(".js"));
197
198 hotReload(jsResource, jsResult.value().content);
199
200 return Void();
201}
202
203void RuntimeWrapper::hotReload(const Valdi::StringBox& bundleName,
204 const Valdi::StringBox& path,

Callers 2

TEST_PFunction · 0.45
TEST_PMethod · 0.45

Calls 10

ResourceIdClass · 0.85
getBundleMethod · 0.80
getJsMethod · 0.80
getJavaScriptRuntimeMethod · 0.80
updateResourcesMethod · 0.80
valueMethod · 0.65
appendMethod · 0.65
VoidClass · 0.50
toBytesViewMethod · 0.45

Tested by

no test coverage detected