Skip to content

Commit

Permalink
CHANGE #791 set enumerable for non-privates
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Sep 13, 2018
1 parent bbf3153 commit 0090123
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export class HeroesListComponent implements OnInit, OnDestroy {
.sort({ name: 1 })
.$;
this.sub = heroes$.subscribe(heroes => {
console.log('heroes:');
console.dir(heroes);

this.heroes = heroes;
this.zone.run(() => { });
});
Expand Down
18 changes: 16 additions & 2 deletions src/rx-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,32 @@ export class RxCollection {
const props = Object.getOwnPropertyNames(obj);
props.forEach(key => {
const desc = Object.getOwnPropertyDescriptor(obj, key);


/**
* When enumerable is true, it will show on console.dir(instance)
* To not polute the output, only getters and methods are enumerable
*/
let enumerable = true;
if (
key.startsWith('_') ||
key.endsWith('_') ||
key.startsWith('$') ||
key.endsWith('$')
) enumerable = false;

if (typeof desc.value === 'function') {
// when getting a function, we automatically do a .bind(this)
Object.defineProperty(proto, key, {
get() {
return desc.value.bind(this);
},
enumerable: false,
enumerable,
configurable: false
});

} else {
desc.enumerable = false;
desc.enumerable = enumerable;
desc.configurable = false;
if (desc.writable)
desc.writable = false;
Expand Down

0 comments on commit 0090123

Please sign in to comment.