2.3.0 - 2.5.0
2.5.0
π implemented deleteMapFunctionFor
method for deleting one specific map function. It may be useful, if you register map function in React useEffect
, and want to clear dependency on effect clearing, like:
import { useEffect } from 'react';
import { Mapper, MapFunction } from '@tomas-light/mapper-js';
class Foo {
name?: string;
}
class Bar {
title?: string;
}
const Page = () => {
useEffect(() => {
Mapper.addMapFunctions(
new MapFunction(Foo, Bar, (foo) => ({
title: foo.name
}))
)
return () => {
Mapper.deleteMapFunctionFor(Foo, Bar);
}
}, []);
return (...)
}
2.4.0
π implemented clear
method for clearing registered dependencies. It may be useful, if you register map function in React useEffect
, and want to clear dependency on effect clearing, like:
import { useEffect } from 'react';
import { Mapper, MapFunction } from '@tomas-light/mapper-js';
class Foo {
name?: string;
}
class Bar {
title?: string;
}
const Page = () => {
useEffect(() => {
Mapper.addMapFunctions(
new MapFunction(Foo, Bar, (foo) => ({
title: foo.name
}))
)
Mapper.addMapFunctions(
new MapFunction(Bar, Foo, (foo) => ({
name: foo.title
}))
)
return () => {
Mapper.clear();
}
}, []);
return (...)
}
π¨ updated typescript from 5.2.2 to 5.5.3
π¨π§ MapFunction required both generic types now
import { MapFunction } from '@tomas-light/mapper-js';
// for example in case, when you define your own function that accepts map function arguments. You need now to explicitly specify both generics as `any` or `object`
// before
function myFunction(...mapFunctions: MapFunction[]) {}
// after
function myFunction(...mapFunctions: MapFunction<any, any>[]) {}
2.3.0
π¨ updated typescript from 4.9.5 to 5.2.2