This is a migrated thread and some comments may be shown as answers.

Using EverliveSDK Classes in my code

1 Answer 16 Views
JavaScript SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Viktor
Top achievements
Rank 1
Viktor asked on 23 Feb 2017, 04:50 PM

Hi guys,

How can I use the classes and interfaces defined for the SDK in my code?

I would like to be able to define an object that represents a User and use the same definition that is used in the EverliveSDK for validation purposes.

I've already added the definitions, but I can use them only for autocomplete and inline documentation.

 

Thanks,

Viktor

1 Answer, 1 is accepted

Sort by
0
Georgi Prodanov
Telerik team
answered on 24 Feb 2017, 10:22 AM
Hi Viktor,

The SDK exposes only interfaces for the objects we use, and almost no classes. All of these interfaces are located in the everlive-sdk/dist/declarations/everlive/interfaces folder. I am not sure I understand your question correctly, but if you would like to instantiate the User class we use and take advantage of validations already in place, this won't be possible, since it's just an interface. You could make a class, which implements it and put validations in it, if you wish to have validation in your models.

Here is a proposed structure to get you going:

import { Item } from '../../../node_modules/everlive-sdk/dist/declarations/everlive/interfaces/Item';
 
export class ItemModel implements Item {
    CreatedAt: Date;
    CreatedBy: string;
    .... all the necessary properties
}

import { ItemModel } from './item.model';
import { User as BsUser } from '../../../node_modules/everlive-sdk/dist/declarations/everlive/interfaces/User';
 
export class User extends ItemModel implements BsUser {
    constructor(
        public Username: string,
        public DisplayName: string,
        .... all the necessary properties
    ) {
        super();
    }
}


I hope this works for you, or at least points you in the right direction. Let us know if you need any more assistance.

Regards,
Georgi Prodanov
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
JavaScript SDK
Asked by
Viktor
Top achievements
Rank 1
Answers by
Georgi Prodanov
Telerik team
Share this question
or