Closed MarcLoupias closed 7 years ago
Oh, right. The article was written before this change: https://github.com/stampit-org/stamp-specification/issues/93 Thank you for finding it!
Basically, the first argument is considered an options object. Thus, should never be undefined. You can manually specify null
which is an object typeof null === 'object'
.
Let me fix the article.
The article should be fixed now.
Thank you for the great issue!
Oooookayyyyy ;)
It's crystal clear now.
It imply that factory function have to takes an object as param.
We cannot do that const myInstance = FactoryFn(val1, val2 ...)
We have to do that const myInstance = FactoryFn({prop1: 'val1', prop2: 'val2', ...})
To be honest the rtype spec to describe stamps add a step in the library adoption. You want to learn stamp but you have to learn rtype + stamp. Javascript executable examples in addition to the rtype def in the stamp-specification repo would be valuable.
Thanks !
EDIT : In fact it is obvious when thinking about it. Should be really obvious for seasoned functional programming developpers which is not my case, everything is new to me.
Hello,
i am playing with codes examples in the Fun with Stamps medium.com articles series.
Just found something strange in the Breaking down a stamp into pieces from the first article code examples :
When the initializer receive no value at all, the stamp lib replace
undefined
by an empty literal object, so theif
statement istrue
instead offalse
, and the default value is overwritten with the literal object.I am using
stampit@3.2.1
and node6.11.3
.