mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add ng-facebook typings
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/// <reference path="ng-facebook.d.ts" />
|
||||
|
||||
{
|
||||
let $facebookProvider: angular.ngFacebook.IFacebookProvider;
|
||||
|
||||
$facebookProvider
|
||||
.setAppId("764262530321266")
|
||||
.setPermissions(["email", "user_friends"])
|
||||
.setPermissions("user_friends")
|
||||
.setCustomInit({
|
||||
xfbml: true
|
||||
})
|
||||
.setVersion("v2.2");
|
||||
|
||||
let appId: string = $facebookProvider.getAppId();
|
||||
let version: string = $facebookProvider.getVersion();
|
||||
let permissions: string = $facebookProvider.getPermissions();
|
||||
let customInit: any = $facebookProvider.getCustomInit();
|
||||
}
|
||||
|
||||
{
|
||||
let $facebook: angular.ngFacebook.IFacebookService;
|
||||
|
||||
let customInit: FBInitParams = $facebook.config<FBInitParams>("customInit");
|
||||
let version: string = $facebook.config<string>("version");
|
||||
let appId: string = $facebook.config<string>("appId");
|
||||
|
||||
$facebook.init();
|
||||
|
||||
$facebook.setCache("key1", 123);
|
||||
$facebook.setCache<{ prop1: number }>("key2", { prop1: 456 });
|
||||
let cache: number = $facebook.getCache<number>("key");
|
||||
$facebook.clearCache();
|
||||
|
||||
let isConnected: boolean = $facebook.isConnected();
|
||||
|
||||
let authResponse: {} = $facebook.getAuthResponse();
|
||||
|
||||
$facebook.getLoginStatus().then(status => { });
|
||||
$facebook.getLoginStatus(true).then(status => { });
|
||||
|
||||
$facebook.logout().then(() => { });
|
||||
$facebook.login().then(() => { });
|
||||
|
||||
$facebook.api("/me").then(user => { });
|
||||
$facebook.api("/me", "get");
|
||||
$facebook.api("/me", { param: 1 });
|
||||
$facebook.api("/me", "get", { param: 1 });
|
||||
|
||||
$facebook.cachedApi("'/me/friends").then(friends => { });
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
// Type definitions for ng-facebook
|
||||
// Project: https://github.com/GoDisco/ngFacebook
|
||||
// Definitions by: Crevil <https://github.com/Crevil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../fbsdk/fbsdk.d.ts" />
|
||||
|
||||
declare namespace angular.ngFacebook {
|
||||
interface IFacebookProvider {
|
||||
setAppId(appId: string): IFacebookProvider;
|
||||
getAppId(): string;
|
||||
|
||||
setVersion(version: string): IFacebookProvider;
|
||||
getVersion(): string;
|
||||
|
||||
setPermissions(permissions: string|Array<string>): IFacebookProvider;
|
||||
getPermissions(): string;
|
||||
|
||||
setCustomInit(customInit: FBInitParams): IFacebookProvider;
|
||||
getCustomInit(): FBInitParams;
|
||||
}
|
||||
|
||||
interface IFacebookService {
|
||||
config<T extends string|number|FBInitParams>(property: string): T;
|
||||
init(): void;
|
||||
|
||||
setCache<T>(attr: string, val: T): void;
|
||||
getCache<T>(attr: string): T;
|
||||
clearCache(): void;
|
||||
|
||||
isConnected(): boolean;
|
||||
getAuthResponse(): {};
|
||||
getLoginStatus(force?: boolean): angular.IPromise<{}>;
|
||||
login(permissions?: string, rerequest?: boolean): angular.IPromise<{}>;
|
||||
logout(): angular.IPromise<void>;
|
||||
|
||||
ui(params: FBUIParams): angular.IPromise<any>;
|
||||
api(path: string): angular.IPromise<{}>;
|
||||
api(path: string, method: string): angular.IPromise<{}>;
|
||||
api(path: string, params: Object): angular.IPromise<{}>;
|
||||
api(path: string, method: string, params: Object): angular.IPromise<{}>;
|
||||
|
||||
cachedApi(path: string): angular.IPromise<any>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user