UNPKG

@react-native-ohos/react-native-get-random-values

Version:

This project is based on [react-native-get-random-values](https://github.com/LinusU/react-native-get-random-values)

29 lines (25 loc) 1.04 kB
/* * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved * Use of this source code is governed by a MIT license that can be * found in the LICENSE file. */ import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts'; import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts'; import { TM } from './generated/ts' import { RNGetRandomValuesTurboModule } from './RNGetRandomValuesTurboModule'; class RNGetRandomValuesTurboModuleFactory extends TurboModulesFactory { createTurboModule(name: string): TurboModule | null { if (this.hasTurboModule(name)) { return new RNGetRandomValuesTurboModule(this.ctx); } return null; } hasTurboModule(name: string): boolean { return name === TM.GetRandomValuesNativeModule.NAME; } } export class RNGetRandomValuesPackage extends RNPackage { createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory { return new RNGetRandomValuesTurboModuleFactory(ctx); } }