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
<div class="container"> | |
<h1 data-bind="text: $parent.eventBus.myProp()"></h1> | |
</div> |
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
import * as ko from 'knockout'; | |
// ...imports omitted... | |
import {EventBus} from './EventBus'; | |
export default class CoffeeRoundViewModel { | |
// ...other vars omitted... | |
private eventBus = EventBus.getInstance(); |
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
import * as ko from 'knockout'; | |
// ...other imports omitted... | |
import { EventBus } from './EventBus'; | |
let _instance: number = 0; | |
export default class CoffeeRoundWebPart extends BaseClientSideWebPart<any> { | |
private _id: number; | |
private eventBus = EventBus.getInstance(); |
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
import * as ko from 'knockout'; | |
export class EventBus { | |
private static _instance:EventBus = new EventBus(); | |
// props for pub-sub | |
public myProp:KnockoutObservable<string> = ko.observable(''); | |
constructor(){ |
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
// remove everything else in constructor, except the super call | |
public constructor(context: IWebPartContext) { | |
super(context); | |
this._id = _instance++; | |
} | |
// create your own 'init' function, to be called a little later in the lifecycle: | |
private doInitStuff() : void | |
{ | |
const tagName: string = `ComponentElement-${this._id}`; |
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
import * as ko from 'knockout'; | |
import styles from './CoffeeRound.module.scss'; | |
import { IWebPartContext } from '@microsoft/sp-client-preview'; | |
import { CRItemModel } from './CRItemModel'; | |
import pnp from 'sp-pnp-js'; | |
import ListService from './ListService'; | |
import {EventBus} from './EventBus'; | |
export default class CoffeeRoundViewModel { |
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
import * as ko from 'knockout'; | |
import styles from './CoffeeRound.module.scss'; | |
import { IWebPartContext } from '@microsoft/sp-client-preview'; | |
import { CRItemModel } from './CRItemModel'; | |
import pnp from 'sp-pnp-js'; | |
import ListService from './ListService'; | |
import {EventBus} from './EventBus'; | |
export default class CoffeeRoundViewModel { |