From 37fb7e162a1e4b64d2d31d23029bf6f16efbc531 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 19 Jul 2016 14:23:23 +0200 Subject: [PATCH] update config handling --- example/app.js | 7 ++++--- src/settings.js | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/example/app.js b/example/app.js index 829f75d..4dfebd0 100644 --- a/example/app.js +++ b/example/app.js @@ -1,9 +1,10 @@ import THREE from 'three.js'; import * as SLICER from 'src/index'; -const settings = new SLICER.Settings(); -settings.updateConfig(SLICER.printerSettings['ultimaker2go']); -settings.updateConfig(SLICER.userSettings); +const settings = new SLICER.Settings({ + ...SLICER.printerSettings['ultimaker2go'], + ...SLICER.userSettings +}); const geometry = new THREE.TorusGeometry(20, 10, 30, 30); diff --git a/src/settings.js b/src/settings.js index 1eb72fc..33fc821 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,11 +1,9 @@ export default class { - constructor() { - this.config = {}; + constructor(config = {}) { + this.config = config; } updateConfig(config) { - for (const i in config) { - this.config[i] = config[i]; - } + this.config = { ...this.config, ...config }; return this; }