FromJS with object type file (file download)

immutable js - fromJS: accessing a file download (array of Object file) seems impossible to convert as immutable

fromJSdoes an excellent job even with nested structures , for example:

javascript const nested = [ { id: 1, val1: '1, other: { id: 1, prop1: '0' } }, true ];

BUT

  • So far, the object String(MyObject)= [object Object] fromJSconverts it as Map().

  • But when the object is a file String(MyFileObject)= [object File], fromJSleave it[object File]

Q1: How (I mean the best way) deal with downloading a file with immutable js?

Q2: Is there some FileMap (equivalent to Map, but a mirror for an object) for this case?

+4
source share
1 answer

. , , .

, , ES6? , , . reviver fromJS, :

function reviver(key, value) {
  if (value instanceof File)  {
    return wrapFile(value);
  }
  return isKeyed(value) ? value.toMap() : value.toList()
}
0

Source: https://habr.com/ru/post/1662758/


All Articles