-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(other): Add Storage support (#7888)
Co-authored-by: Salakar <mike@invertase.io>
- Loading branch information
Showing
15 changed files
with
674 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// We need to share firebase imports between modules, otherwise | ||
// apps and instances of the firebase modules are not shared. | ||
export * from 'firebase/app'; | ||
export * from 'firebase/storage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DeviceEventEmitter } from 'react-native'; | ||
|
||
// A general purpose guard function to catch errors and return a structured error object. | ||
export function guard(fn) { | ||
return fn().catch(e => Promise.reject(getWebError(e))); | ||
} | ||
|
||
// Converts a thrown error to a structured error object | ||
// required by RNFirebase native module internals. | ||
export function getWebError(error) { | ||
const obj = { | ||
code: error.code || 'unknown', | ||
message: error.message, | ||
}; | ||
// Split out prefix, since we internally prefix all error codes already. | ||
if (obj.code.includes('/')) { | ||
obj.code = obj.code.split('/')[1]; | ||
} | ||
return { | ||
...obj, | ||
userInfo: obj, | ||
}; | ||
} | ||
|
||
export function emitEvent(eventName, event) { | ||
setImmediate(() => DeviceEventEmitter.emit('rnfb_' + eventName, event)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.