shadow.js
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

API

get(key:string)

Get the current value and all other remaining value

watch(key:string)

Get any new values that are set

also(...keys:string[])

If you want to watch more properties. You can do that

Examples as Test Cases

import "rxjs/add/operator/take"
import "rxjs/add/operator/finally"
import {expect} from "chai"
import { Shadow } from 'shadow.js';

describe("Shadow",()=>{

    function setup(){
        return Shadow.create({
            name:"Shavyg",
            age:27
        })
    }

    let person = setup();

    beforeEach(()=>person=setup());


    //you can watch for a propert change on anything

    it("Should be able to watch shaded properties",(done)=>{
        Shadow(person).watch("name").subscribe(()=>{
            done();
        });
        person.name = "Pizza";
        person.age = 1000;
    })




    it("Should be able to get shaded properties",(done)=>{
        Shadow(person).get("name").take(2).finally(done).subscribe();
        person.name = "Pizza";
        person.age = 1000;
    })


    it("should be able to shadow new properties",(done)=>{

        Shadow(person).also("race")

        Shadow(person).watch("race").take(1).subscribe(()=>{
            done();
        });

        (person as any).race = "super";
    })


    afterEach(()=>{
        Shadow(person).clear();
    })

})

Readme

Keywords

none

Package Sidebar

Install

npm i shadow.js

Weekly Downloads

0

Version

1.0.2

License

ISC

Last publish

Collaborators

  • shavyg2