-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fbt): Add ability to provide your own ViewerContext dynamically
Reviewed By: jrwats Differential Revision: D21593501 fbshipit-source-id: 030470e650836e9e7f570190a993d82ad2ad9dd5
- Loading branch information
1 parent
f58d7c2
commit df2414a
Showing
22 changed files
with
225 additions
and
136 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
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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* An empty no-op for now. | ||
*/ | ||
const FbtEnv = { | ||
setup() {}, | ||
setupOnce() {}, | ||
}; | ||
|
||
module.exports = FbtEnv; |
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
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
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,56 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @emails oncall+internationalization | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
/* eslint-disable fb-www/flow-exact-by-default-object-types */ | ||
|
||
import type { | ||
FbtHookRegistrations, | ||
FbtResolvedPayload, | ||
FbtRuntimeCallInput, | ||
FbtTranslatedInput, | ||
} from 'FbtHooks'; | ||
import typeof IntlViewerContext from 'IntlViewerContext'; | ||
|
||
const _registrations: FbtHookRegistrations = {}; | ||
const FbtHooksImpl = { | ||
getErrorListener(context: FbtErrorContext): ?IFbtErrorListener { | ||
return _registrations.errorListener?.(context); | ||
}, | ||
|
||
logImpression(hash: string): void { | ||
_registrations.logImpression?.(hash); | ||
}, | ||
|
||
onTranslationOverride(hash: string): void { | ||
_registrations.onTranslationOverride?.(hash); | ||
}, | ||
|
||
// TODO: T61015960 - get off `mixed` and onto something more locked down (Fbs) | ||
getFbsResult(input: FbtResolvedPayload): mixed { | ||
return _registrations.getFbsResult(input); | ||
}, | ||
|
||
// TODO: T61015960 - get off `mixed` and onto something more locked down (Fbt) | ||
getFbtResult(input: FbtResolvedPayload): mixed { | ||
return _registrations.getFbtResult(input); | ||
}, | ||
|
||
getTranslatedInput(input: FbtRuntimeCallInput): FbtTranslatedInput { | ||
return _registrations.getTranslatedInput?.(input) ?? input; | ||
}, | ||
|
||
getViewerContext(): IntlViewerContext { | ||
return _registrations.getViewerContext(); | ||
}, | ||
|
||
register(registrations: FbtHookRegistrations): void { | ||
Object.assign(_registrations, registrations); | ||
}, | ||
}; | ||
|
||
module.exports = FbtHooksImpl; |
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
Oops, something went wrong.