Skip to content

Commit

Permalink
chore(docs): Rearrenge structure of the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Jul 23, 2023
1 parent 0b12f1c commit 7ff62fd
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,31 @@ Firstly install all the adapters you want to support and lock the version.
export { default } from "@date-io/date-fns";
```

#### 3. Use it for date-time management

Register it using your library context. It may be react context, dependency injection container or any other tool that allows the user to register the used library **1 time**.

```tsx
// react example
import { createMyAdapter } from "your-awesome-lib/adapters/date-fns";

<DateLibProvider adapter={createMyAdapter({ locale: "fr" })}>
{/* ... */}
</DateLibProvider>;
```

And use the interface of date-io (or your custom interface).

```ts
import { IUtils } from "@date-io/core/IUtils";

function myFunctionInLibrary<TDate>(date: TDate, adapter: IUtils<TDate>) {
// ...
const weekArray = adapter.getWeekArray(Date);
// ...
}
```

### Overriding behavior

It is possible to change or extend the behavior of any adapter by simply inheriting and overriding the base class of utils while saving the same interface.
Expand Down Expand Up @@ -321,28 +346,3 @@ export const createMyAdapter(options) {
return adapter
}
```

#### 3. Use it for date-time management

Register it using your library context. It may be react context, dependency injection container or any other tool that allows the user to register the used library **1 time**.

```tsx
// react example
import { createMyAdapter } from "your-awesome-lib/adapters/date-fns";

<DateLibProvider adapter={createMyAdapter({ locale: "fr" })}>
{/* ... */}
</DateLibProvider>;
```

And use the interface of date-io (or your custom interface).

```ts
import { IUtils } from "@date-io/core/IUtils";

function myFunctionInLibrary<TDate>(date: TDate, adapter: IUtils<TDate>) {
// ...
const weekArray = adapter.getWeekArray(Date);
// ...
}
```

0 comments on commit 7ff62fd

Please sign in to comment.