This differential enables JS code on both Android and iOS to subscribe to auth metadata events.
Details
- Apply this patch: https://gist.github.com/marcinwasowicz/8ae2a80f5f8dfd0708f9496182d861bb. It is the same as for previous diffs but this time we use Js file that is comitted in this differential.
- Build Android and iOs apps.
- In each ensure that every time you type letter in message input you can see console.log with dummy auth metadata.
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
native/event-emitters/csa-auth-metadata-emitter.js | ||
---|---|---|
13 | This is actually how react native constructs JS object from native module that exports some constants. All constants exported from getConstants method automatically become properties of the object. |
native/event-emitters/csa-auth-metadata-emitter.js | ||
---|---|---|
20–26 | Why is it an array of objects? | |
21–25 | Not directly related to this diff but this type should be extracted and exist somewhere in lib/, we're starting to duplicate it in various places across codebase, e.g. type BackupAuth, type IdentityInfo. I have a suspicion that @varun is using this one extensively too, maybe it's already done as a part of his work, cc @varun |
native/event-emitters/csa-auth-metadata-emitter.js | ||
---|---|---|
21–25 | yeah you can find this in lib/types/identity-service-types.js now |
native/event-emitters/csa-auth-metadata-emitter.js | ||
---|---|---|
20–26 | This is the beginning of JS definition of NativeEventEmitter class: export default class NativeEventEmitter<TEventToArgsMap: {...}> implements IEventEmitter<TEventToArgsMap> So it is typed by the map of event names to array of arguments that listener callbacks will take. Then addListener method takes as an argument callback function that is typed by unwinding the array passed to NatuveEventEmitter type: addListener<TEvent: $Keys<TEventToArgsMap>>( eventType: TEvent, listener: (...args: $ElementType<TEventToArgsMap, TEvent>) => mixed, context?: mixed, ) In our case listener callback will take one argument so it is one-element array. |
native/event-emitters/csa-auth-metadata-emitter.js | ||
---|---|---|
20–26 | Ahh right. Thanks for detailed explanation! |