mgechev / mgechev/angular2-hot-loader
Hot reload a component's constructor
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 113
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
I suppose that this could be implemented using the following `clone` function in the `updatePrototype` method. This was taken from [here](https://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object).
``` javascript
function clone(obj) {
var copy;
// Handle the 3 simple types, and null or undefined
if (null == obj || "object" != typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
copy.setTime(obj.getTime());
return copy;
}
// Handle Array
if (obj instanceof Array) {
copy = [];
for (var i = 0, len = obj.length; i < len; i++) {
copy[i] = clone(obj[i]);
}
return copy;
}
// Handle Object
if (obj instanceof Object) {
copy = {};
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = clone(obj[attr]);
}
return copy;
}
throw new Error("Unable to copy obj! Its type isn't supported.");
}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the updatePrototype method mentioned in the issue and inspect how component constructors are currently handled. Evaluate the proposed clone approach in that context, then verify that a component constructor can be hot-reloaded as requested; no specific test or acceptance criteria are provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100