Skip to content

Instantly share code, notes, and snippets.

@mhevery
Last active June 1, 2017 08:06

Revisions

  1. mhevery revised this gist Dec 19, 2015. 5 changed files with 82 additions and 8 deletions.
    18 changes: 18 additions & 0 deletions example.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    // https://gist.github.com/mhevery/4b1bdb59a8c16f9cbe76


    /// <reference path="probe.d.ts" />

    ///////////////////////
    /// WORK IN PROGRESS //
    ///////////////////////

    var appRef: ApplicationRef = ng.platform.applications[0];

    // To force Change Detection
    appRef.tick();

    // To get a hold of spcefic component

    var settings: Probe = appRef.probe('app-cmp > settings');
    var user: BindingSet = settings.binding('user');
    47 changes: 47 additions & 0 deletions probe.d.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    // https://gist.github.com/mhevery/4b1bdb59a8c16f9cbe76

    ///////////////////////
    /// WORK IN PROGRESS //
    ///////////////////////


    declare module ng {
    var platform: Platform;
    }

    interface Platform {
    applications: ApplicationRef[];
    }

    interface ApplicationRef {
    tick(): void;

    /**
    * selector is a simple CSS selector combined with
    * concatinators which allows easy traversal of the
    * View tree.
    *
    * NOTE: this selects over logical components not over
    * (some CSS langugae which would be easy to implement
    * and allows us to walk the tree)
    *
    * concatinators
    * - ' ' (space) recursive content/view descendant
    * - `>` direct content/view descendant
    * - `:view` direct view
    *
    * # examples
    *
    * `app-comp calendar:view`
    *
    */
    probe(selector: string): Probe;
    }

    interface Probe {
    binding(selector: string): BindingSet;
    }

    interface BindingSet {
    value: any[];
    }
    7 changes: 0 additions & 7 deletions probe.ts
    Original file line number Diff line number Diff line change
    @@ -1,7 +0,0 @@
    declare interface Window {
    ng: Angular
    }

    interface Angular {

    }
    17 changes: 17 additions & 0 deletions requirements.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Constraints

    [latest gist](https://gist.github.com/mhevery/4b1bdb59a8c16f9cbe76)

    ## WebWorkers

    The API must be on the web-worker side, and must not depend on
    DOM. It is not even clear if there even is a DOM, in the case
    of Native UI.

    ## Shadow DOM & Selectors

    Shadow DOM and selectors are tricky since they can not be used
    with `querySelector`. (It does not pierce shadow DOM boundries)
    For this reason it is better not to rely on the `querySelector`
    at all and have a query mechanism of a tree. A custom query
    mechanism would be compatible with Native UI / WebWorkers.
    1 change: 0 additions & 1 deletion sample_usage.ts
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    var appRef = ng.
  2. mhevery revised this gist Dec 19, 2015. 2 changed files with 6 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion probe.ts
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    declare interface Window {
    ng:
    ng: Angular
    }

    interface Angular {

    }
    1 change: 1 addition & 0 deletions sample_usage.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    var appRef = ng.
  3. mhevery created this gist Dec 19, 2015.
    3 changes: 3 additions & 0 deletions probe.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    declare interface Window {
    ng:
    }