Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Cursor<IEventsList>

Already mixed class. Plug and play.

Type parameters

Hierarchy

Indexable

[key: string]: any

Already mixed class. Plug and play.

Index

Constructors

Static constructor

  • new Cursor(id?: string): any
  • Parameters

    • Optional id: string

    Returns any

Properties

Static data

data: any

Data of cursor, changing at every cursor.apply()

Static emitter

emitter: EventEmitter

Static id

id: string

Static isDestroyed

isDestroyed: boolean

Static query

query: any

Abstract query for some source, which makes the source be able to send bundles to this cursor.

Static queryId

queryId: string

Unic id for every execution of query.

Methods

Static apply

  • Apply bundle to cursor and emit 'changed' event.

    example
    
    import { Cursor } from 'ancient-cursor/lib/cursor';
    
    const cursor = new Cursor();
    cursor.exec(true, { a: [{ b: { c: 'd' } }] });
    
    cursor.data; // { a: [{ b: { c: 'd' } }] }
    
    cursor.apply({
      type: 'set',
      path: 'a.0',
      value: { d: { e: 'f' } },
    });
    
    cursor.data; // { a: [{ d: { e: 'f' } }] }
    

    Parameters

    Returns this

Static destroy

  • destroy(): void
  • Returns void

Static emit

  • emit<IE>(eventName: IE, data: IEventsList[IE]): this
  • Type parameters

    • IE: keyof IEventsList

    Parameters

    • eventName: IE
    • data: IEventsList[IE]

    Returns this

Static exec

  • exec(query: any, data?: any): this
  • Initiate query execution for some source and set data for this cursor.

    example
    
    import { Cursor } from 'ancient-cursor/lib/cursor';
    
    const cursor = new Cursor();
    
    cursor.exec(true, { a: [{ b: { c: 'd' } }] });
    
    cursor.data; // { a: [{ d: { e: 'f' } }] }
    cursor.query; // true
    cursor.queryId; // some generated id
    

    Parameters

    • query: any
    • Optional data: any

    Returns this

Static generateId

  • generateId(): string
  • Returns string

Static get

  • Get data by path from cursor.

    example
    import { Cursor } from 'ancient-cursor/lib/cursor';
    
    const cursor = new Cursor();
    cursor.exec(true, { a: [ { x: 2, b: 123 } ] });
    
    cursor.data; // { a: [ { x: 2, b: 123 } ] }
    
    cursor.get("a.0[b]"); // 123
    cursor.get(['a',0,'b']); // 123
    cursor.get(['a',{ x: 2 },'b']); // 123
    
    

    Parameters

    Returns any

Static off

  • off<IE>(eventName: IE, listener: function): this
  • Type parameters

    • IE: keyof IEventsList

    Parameters

    • eventName: IE
    • listener: function
        • (data: IEventsList[IE]): void
        • Parameters

          • data: IEventsList[IE]

          Returns void

    Returns this

Static on

  • on<IE>(eventName: IE, listener: function): this
  • Type parameters

    • IE: keyof IEventsList

    Parameters

    • eventName: IE
    • listener: function
        • (data: IEventsList[IE]): void
        • Parameters

          • data: IEventsList[IE]

          Returns void

    Returns this

Static once

  • once<IE>(eventName: IE, listener: function): this
  • Type parameters

    • IE: keyof IEventsList

    Parameters

    • eventName: IE
    • listener: function
        • (data: IEventsList[IE]): void
        • Parameters

          • data: IEventsList[IE]

          Returns void

    Returns this

Static parse

Generated using TypeDoc