// Copyright 2022-present 650 Industries. All rights reserved. #pragma once #ifdef __cplusplus #include namespace jsi = ABI49_0_0facebook::jsi; namespace ABI49_0_0expo { /** A function that is responsible for initializing the backed object. */ typedef std::function(jsi::Runtime &)> LazyObjectInitializer; /** A host object that defers the creating of the raw object until any property is accessed for the first time. */ class JSI_EXPORT LazyObject : public jsi::HostObject { public: using Shared = std::shared_ptr; LazyObject(const LazyObjectInitializer initializer); virtual ~LazyObject(); jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override; void set(jsi::Runtime &, const jsi::PropNameID &name, const jsi::Value &value) override; std::vector getPropertyNames(jsi::Runtime &rt) override; private: const LazyObjectInitializer initializer; std::shared_ptr backedObject; }; // class LazyObject } // namespace ABI49_0_0expo #endif // __cplusplus