Options
All
  • Public
  • Public/Protected
  • All
Menu

External module Content

description

Top level base type of sense NET's Type hierarchy. Content has the basic properties and functionality that can be reached on all of the inherited types. It's almost the same as an abstract class, it may not be instantiated directly, but it has the basic methods implemented that can be called on obejcts with derived types. Unlike other Content Types it is not autogenerated. Content has the basic properties and functionality that can be reached on all of the inherited types. It's almost the same as an abstract class, it may not be instantiated directly, but it has the basic methods implemented that can be called on obejcts with derived types.

See the Pen @sensenet/sn-client-js/content by gallayl (@gallayl) on CodePen.

Unlike other Content Types it is not autogenerated.

Actions

Built-in SenseNet Actions on client-side are methods on the Content object. If you want to use them you have to have a Content which can be made with the Create method that can convert your js Object or JSON with the proper parameters to a Content with the given type.

var content = Content.Create('Folder', {DisplayName: 'My folder'});

On a Content object the Actions can be called like this way (check below sections for further information about the Actions and their params):

let contentDelete = content.Delete(false);

This function returns an Observable so that you can subscribe to it in your code. This way you can work with the response easier defining the three functions of a subscribtion and using all the super helpful and usable features like filtering, combining, caching, etc.

contentDelete.subscribe({
 .map(response => response.d) //map and use the reponse's 'd' object as the response
 .subscribe({
     next: response => console.log(response), //if the request was successful
     error: error => console.error('something wrong occurred: ' + error), //if the request failed
     complete: () => console.log('done'), //if the request is done
 })
});

Using RxJS you are able to merge, zip or combine multiple Observables, this way you can develope various combinations of Actions with custom functionality.

Read more about RxJS here

And about Reactive Programming here it could be helpful not only with ajax request but also with event handling or anything else related to async data streams.

Index

Type aliases

Content

Content: ContentInternal<T> & T

Generic type alias for a Content representation. It's possible that a content of this type has not been saved yet to the Repository.

SavedContent

SavedContent: ContentInternal<T> & T & ISavedContent

Generic type alias for a saved Content representation. Saved contents have an Id, Path and a Name property

WithParentContent

WithParentContent: T & object

Functions

isContent

  • isContent<T>(object: any): boolean
  • Typeguard that determines if the specified Object is a Content instance

    Type parameters

    Parameters

    • object: any

      The object that needs to be checked

    Returns boolean

isDeferred

  • isDeferred(fieldObject: any): boolean
  • Typeguard that determines if the specified Object is a DeferredObject

    Parameters

    • fieldObject: any

      The object that needs to be checked

    Returns boolean

isIContent

  • isIContent(object: any): boolean
  • Typeguard that determines if the specified Object is an IContentOptions instance

    Parameters

    • object: any

      The object that needs to be checked

    Returns boolean

isIContentList

  • isIContentList(objectList: any[]): boolean
  • Typeguard that determines if the specified Object is an IContentOptions array

    Parameters

    • objectList: any[]

      The object that needs to be checked

    Returns boolean

isSavedContent

  • Typeguard that determines if the specified Content instance is saved.

    Type parameters

    Parameters

    Returns boolean

Generated using TypeDoc