This file contains hidden or 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
class DemoUserService { | |
private getUserProfilePromise: Promise<EGClientUserEntity>; | |
public getUserProfile(forUserID: string): Promise<EGClientUserEntity> { | |
if (!this.getUserProfilePromise) { | |
this.getUserProfilePromise = ... | |
// See here for details: | |
} | |
return this.getUserProfilePromise; |
This file contains hidden or 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
class DemoUserService { | |
private getUserProfilePromise: Promise<EGClientUserEntity>; | |
public getUserProfile(forUserID: string): Promise<EGClientUserEntity> { | |
if (!this.getUserProfilePromise) { | |
this.getUserProfilePromise = new Promise<EGClientUserEntity>((resolve, reject) => { |
This file contains hidden or 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
return new Promise<SomeModel> ( (resolve, reject) => { | |
try { | |
// logic goes here | |
} | |
catch (exception) { | |
const errMsg = { | |
msg: '[ServiceName]: [methodName]: ERROR! Failed to do the thing.', | |
errDetails: exception | |
}; | |
console.error(errMsg); |
This file contains hidden or 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
private async handleConfirmAdvanceWorkflow() { | |
this.setState( | |
{ | |
isAdvancingWorkflow: true, | |
didAdvanceWorkflow: false, | |
wasErrorAdvancingWorkflow: false | |
} as DraftResearchApproveOMaticState); |
This file contains hidden or 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
public onInit(): Promise<void> { | |
return new Promise<void>( (resolve, reject) => { | |
DocumentsService.initializeInstance(this.context); | |
WorkflowService.initializeInstance(this.context); | |
resolve(); | |
}); | |
} | |
This file contains hidden or 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 SPHttpClient from '@microsoft/sp-http/lib/spHttpClient/SPHttpClient'; | |
import WebPartContext from '@microsoft/sp-webpart-base/lib/core/WebPartContext'; | |
import { ConfigService } from '../../framework/services/ConfigService/ConfigService'; | |
export class WorkflowService { | |
private static instance: EGWorkflowService; | |
private constructor(private context: WebPartContext) { | |
this.initialize(); |
This file contains hidden or 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
class SearchableCat implements IBinarySearchable { | |
// placeholders | |
public IsEqualTo(value): boolean { return true; }; | |
public IsLessThan(value): boolean { return true; }; | |
public IsGreaterThan(value): boolean { return true; }; | |
public CatName: string; | |
public PreferredFood: "Wet" | "Dry"; | |
public Age: number; |
This file contains hidden or 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
class SearchableCar implements IBinarySearchable { | |
// placeholders | |
public IsEqualTo(value): boolean { return true; }; | |
public IsLessThan(value): boolean { return true; }; | |
public IsGreaterThan(value): boolean { return true; }; | |
public CarName: string; | |
public CarType: "Convertible" | "Four Door" | "Classic"; |
This file contains hidden or 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
interface IBinarySearchable { | |
IsEqualTo(value): boolean; | |
IsLessThan(value): boolean; | |
IsGreaterThan(value): boolean; | |
} | |
class BinarySearcher { | |
static Search<T extends IBinarySearchable>(searchIn: T[], searchFor: any){ | |
This file contains hidden or 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
# | |
// Starting with ClientContext, the constructor requires a URL to the | |
// server running SharePoint. | |
ClientContext context = new ClientContext("http://SiteUrl"); | |
// Assume that the web has a list named "Announcements". | |
List announcementsList = context.Web.Lists.GetByTitle("NewsTicker"); | |
// We are just creating a regular list item, so we don't need to | |
// set any properties. If we wanted to create a new folder, for |
NewerOlder