Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.

Bridget

Demetrios Skamiotis edited this page Jul 2, 2020 · 8 revisions

@guardian/bridget

In very simple terms Bridget acts as a sort of API between the Apps Rendering and Swift codebases.

Ensuring Type and Parameter Integrity

We define all Types and Services in native.thrift to ensure Type and Parameter Integrity

An API between native layers (iOS, Android) and Webview.

It converts the types and services conveniently into JavaScript and Swift automatically. The thrift files are published the thrift to NPM as a Package to be used, as well as a Swift Package.

  • Merging into master will automatically run the GitHub actions to publish packages

This allows a "Bridge" to be created between Apps Rendering and Swift Client Side development in order to share these types and functions.

Generated packages

  • The TypeScript package can be installed from NPM
  • Swift package can be installed with Swift Package Manager from GitHub

The TypeScript package can be installed from NPM Swift package can be installed with Swift Package Manager from GitHub

Processes and Steps:

Within our Bridget Repo in GitHub can be found a native.thrift, which is where we can construct Types and Services (functions).


Upon merging the Repo the following actions take place:

  1. A .yaml configuration file is created to instruct the publishing of the thrift file
  2. Bump Version pushed up tag created (for example package inc++ from 0.51 to 0.52
  3. generate-typescript-package - Publishes to NPM
  4. generate-swift-package - publishes to Bridget-Swift Repo to be used by swift

Example:

Creating a Gallery Fucntion service Gallery { void launchSlideshow(1:list<Image> images, 2:i32 selectedIndex, 3:string articleTitle) }

This is defined in the thrift file Once merged a package is created once published on NPM

  • So when we npm install within apps-rendering it will install all the dependancies and packages required
  • From apps-rendering/package.json - we update the version of "@guardian/bridget": "^0.64"
  • We can then import and use the "service Gallery" function adding any logic with parameters such as Height, Width (as defined in the thrift)
  • The client side development can also take advantage of this Function taking into account and utilising the types as needed.
  • fetches the package from Bridget-Swift, the iOS developer would implement the logic of the functions.
  • In addition Swift can "fetch" the function and its further logic from apps-rendering.

Clone this wiki locally