Skip to content

Instantly share code, notes, and snippets.

@Teevio
Last active January 28, 2016 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Teevio/d7172e160a3aa67696fc to your computer and use it in GitHub Desktop.
Save Teevio/d7172e160a3aa67696fc to your computer and use it in GitHub Desktop.
// If you don't care about IE
jsConfig.pageData = Object.assign({}, jsConfig.pageData, { [path]: data.page })
// If you use Underscore.js
jsConfig.pageData = _.extend(jsConfig.pageData, { [path]: data.page });
// If you use jQuery
jsConfig.pageData = jQuery.extend(true, jsConfig.pageData, { [path]: data.page });
// Just JS
var tempData = (JSON.parse(JSON.stringify(this.someObject)));
tempData[path] = data.page;
jsConfig.pageData = tempData;
@Teevio
Copy link
Author

Teevio commented Jan 27, 2016

When dealing with state and reactivity with Vue.js you will sometimes need to assign a number of properties on to an existing object, for example using Object.assign() or _.extend(). However, new properties added to the object will not trigger changes. In such cases, create a fresh object with properties from both the original object and the mixin object (http://vuejs.org/guide/reactivity.html#Change_Detection_Caveats).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment