Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show computed property dependent keys #779

Closed
lifeart opened this issue Apr 9, 2018 · 5 comments
Closed

Show computed property dependent keys #779

lifeart opened this issue Apr 9, 2018 · 5 comments

Comments

@lifeart
Copy link
Contributor

lifeart commented Apr 9, 2018

Now to get understanding about cp depended keys you need to investigate object in console or taking a look into source code.

Computed property has _dependentKeys array, any ideas how this content can be shown in object debugger?

How to extract all object's computed props?

var emberObject = $E;

Object.keys(temp2.__proto__)
	.filter(key=>typeof emberObject [key] === 'object' && emberObject[key]._dependentKeys)
	.reduce((collector, key)=>{
		collector[key] = emberObject[key]._dependentKeys.slice(0);
		return collector;
	},{})
@lifeart
Copy link
Contributor Author

lifeart commented Apr 9, 2018

more informational case:



var emberObject = $E;

function serializeObject(el) {
	if (Array.isArray(el)) {
		return el;
	}
	if (typeof el === 'object') {
		return JSON.stringify(el);
	}
	return el;
}
Object.keys(temp2.__proto__)
	.filter(key=>typeof emberObject [key] === 'object' && emberObject[key]._dependentKeys)
	.reduce((collector, key)=>{
		let cpKeys = temp2[key]._dependentKeys.slice(0);
		let cpKeysAndVals = [];
		cpKeys.forEach((keyName) => {
			let value = emberObject.get(keyName);
			if (Array.isArray(value)) {
				if (Array.isArray(value[0])) {
					cpKeysAndVals.push(`${keyName} --> [[${serializeObject(value[0][0])}]...]`);
				} else {
					cpKeysAndVals.push(`${keyName} --> [${serializeObject(value[0])}...]`);
				}
				
			} else {
				cpKeysAndVals.push(`${keyName} --> ${serializeObject(value)}`);
			}
			
		});
		collector[key] = cpKeysAndVals
		return collector;
	},{})

@lifeart
Copy link
Contributor Author

lifeart commented Apr 9, 2018

image

an example

@lifeart
Copy link
Contributor Author

lifeart commented Apr 9, 2018

as bonus -> cp dependency graph can be rendered for each object

@nummi
Copy link
Collaborator

nummi commented Apr 29, 2018

@rwwagner90, close?

@RobbieTheWagner
Copy link
Member

This PR was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants