-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 BlobModule #24909
[TM] Add spec for BlobModule #24909
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
const Blob = require('./Blob'); | ||
const BlobRegistry = require('./BlobRegistry'); | ||
const {BlobModule} = require('../BatchedBridge/NativeModules'); | ||
import NativeBlobModule from './NativeBlobModule'; | ||
|
||
import type {BlobData, BlobOptions, BlobCollector} from './BlobTypes'; | ||
|
||
|
@@ -53,7 +53,7 @@ class BlobManager { | |
/** | ||
* If the native blob module is available. | ||
*/ | ||
static isAvailable = !!BlobModule; | ||
static isAvailable = !!NativeBlobModule; | ||
|
||
/** | ||
* Create blob from existing array of blobs. | ||
|
@@ -92,7 +92,7 @@ class BlobManager { | |
} | ||
}, 0); | ||
|
||
BlobModule.createFromParts(items, blobId); | ||
NativeBlobModule.createFromParts(items, blobId); | ||
|
||
return BlobManager.createFromOptions({ | ||
blobId, | ||
|
@@ -131,38 +131,38 @@ class BlobManager { | |
if (BlobRegistry.has(blobId)) { | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot call |
||
} | ||
BlobModule.release(blobId); | ||
NativeBlobModule.release(blobId); | ||
} | ||
|
||
/** | ||
* Inject the blob content handler in the networking module to support blob | ||
* requests and responses. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot call |
||
static addNetworkingHandler(): void { | ||
BlobModule.addNetworkingHandler(); | ||
NativeBlobModule.addNetworkingHandler(); | ||
} | ||
|
||
/** | ||
* Indicate the websocket should return a blob for incoming binary | ||
* messages. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot call |
||
static addWebSocketHandler(socketId: number): void { | ||
BlobModule.addWebSocketHandler(socketId); | ||
NativeBlobModule.addWebSocketHandler(socketId); | ||
} | ||
|
||
/** | ||
* Indicate the websocket should no longer return a blob for incoming | ||
* binary messages. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot call |
||
static removeWebSocketHandler(socketId: number): void { | ||
BlobModule.removeWebSocketHandler(socketId); | ||
NativeBlobModule.removeWebSocketHandler(socketId); | ||
} | ||
|
||
/** | ||
* Send a blob message to a websocket. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot call |
||
static sendOverSocket(blob: Blob, socketId: number): void { | ||
BlobModule.sendOverSocket(blob.data, socketId); | ||
NativeBlobModule.sendOverSocket(blob.data, socketId); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 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 { | ||
+getConstants: () => {|BLOB_URI_SCHEME: string, BLOB_URI_HOST: ?string|}; | ||
+addNetworkingHandler: () => void; | ||
+addWebSocketHandler: (id: number) => void; | ||
+removeWebSocketHandler: (id: number) => void; | ||
+sendOverSocket: (blob: Object, id: number) => void; | ||
+createFromParts: (parts: Array<Object>, blobId: string) => void; | ||
+release: (blobId: string) => void; | ||
} | ||
|
||
export default TurboModuleRegistry.get<Spec>('BlobModule'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot call
NativeBlobModule.createFromParts
because propertycreateFromParts
is missing in null or undefined [1].