Skip to content

Commit

Permalink
Refactor client embed id into a shared constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Colley committed May 7, 2020
1 parent bcdc17d commit a764a46
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/kitchen-sink/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import * as appContext from '@financial-times/dotcom-ui-app-context'
import * as tracking from '@financial-times/n-tracking'
import * as ads from '@financial-times/n-ads'
import * as clientEmbed from '@financial-times/dotcom-ui-client-embed'
import { CLIENT_EMBED_ID } from '../constants.js'

readyState.domready.then(() => {
const flagsClient = flags.init()
const appContextClient = appContext.init()

const clientEmbedClient = clientEmbed.init('custom-context')
const clientEmbedClient = clientEmbed.init(CLIENT_EMBED_ID)
console.log(clientEmbedClient.getAll()) // eslint-disable-line no-console

layout.init()
Expand Down
1 change: 1 addition & 0 deletions examples/kitchen-sink/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const CLIENT_EMBED_ID = 'client-embed'
3 changes: 2 additions & 1 deletion examples/kitchen-sink/server/controllers/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { Shell } = require('@financial-times/dotcom-ui-shell')
const { Layout } = require('@financial-times/dotcom-ui-layout')
const { Slot, AdsOptionsEmbed } = require('@financial-times/n-ads')
const { ClientEmbed } = require('@financial-times/dotcom-ui-client-embed')
const { CLIENT_EMBED_ID } = require('../../constants.js')

module.exports = (_, response, next) => {
try {
Expand Down Expand Up @@ -65,7 +66,7 @@ module.exports = (_, response, next) => {
</section>
</div>
</Layout>
<ClientEmbed id="custom-context" data={{ foo: true, bar: 'qux' }} />
<ClientEmbed id={CLIENT_EMBED_ID} data={{ foo: true, bar: 'qux' }} />
</Shell>
)

Expand Down

0 comments on commit a764a46

Please sign in to comment.