Skip to content

2.3.0 - 2.5.0

Compare
Choose a tag to compare
@tomas-light tomas-light released this 16 Jul 22:46
· 1 commit to main since this release

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