Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ICursor<IEventsList>

Type parameters

Hierarchy

Indexable

[key: string]: any

Index

Constructors

constructor

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

    • Optional id: string

    Returns any

Properties

data

data: any

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

emitter

emitter: EventEmitter

id

id: string

isDestroyed

isDestroyed: boolean

query

query: any

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

queryId

queryId: string

Unic id for every execution of query.

Methods

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

destroy

  • destroy(): void
  • Returns void

emit

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

    • IE: keyof IEventsList

    Parameters

    • eventName: IE
    • data: IEventsList[IE]

    Returns this

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

generateId

  • generateId(): string
  • Returns string

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

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

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

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

parse

Generated using TypeDoc