glenjamin / glenjamin/transit-immutable-js
Initialisation of Record Map
- Dominant language
- JavaScript
- Stars
- 250
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
Hey there!
Great library, I just have one little problem/question about this line of code: see https://github.com/glenjamin/transit-immutable-js/blob/master/index.js#L215
Is there a reason for initialising the Records there? Or rather: is there a reason for initialising them with an empty Object (`{}`)?
In my case, I have Records with a constructor and because of the initialisation of the Record with `{}`, I can't use default parameters (`{ meta : {} }`) and need to check if my nested object structures exist everywhere (`data.meta && data.meta.title || ...`):
```js
export default class StartPage extends StartPageRecord {
constructor(data = { meta : {} }, name) { // this here won't work
super({
...data,
selected : new Set(data.selected),
image : new Image(data.image),
meta : new Meta({
title : data.meta.title || data.title, // these throw errors
description : data.meta.description || data.subtitle // because data.meta is undefined
}),
socialLinks : new SocialLinks(data.socialLinks)
}, name)
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.