1.0.71 • Published 6 days ago

@budarin/tasks-domain v1.0.71

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

tasks-domain

Contains a description of the entities

  • icon
  • priority
  • task category
  • task

their types, constructors, object extraction and validation methods.

It also describes the structure of storing entities in the application state store and methods for changing them for reuse in various applications.

Data model

Data model

Install

yarn add @budarin/tasks-domain

Usage

import type { TasksStoreState } from '@budarin/tasks-domain';
import { tasksStoreState, initTasksStore } from '@budarin/tasks-domain';

import { storeLogger } from '../app/providers';
import { INBOX_KEY, OVERDUE_KEY, RECYCLE_BIN_KEY } from '../app/entities/index.ts';

type AppState = TasksStoreState && SomeOtherState;

useAppStore = create<AppState>()({
    ...tasksStoreState,

    navigationFilter: {...},

    tasks: {
        ...tasksStoreState.tasks,

        idsByExpireDate: {},
        idsByCategoryId: {},
        idsByFilterId: {
            [INBOX_KEY]: [],
            [RECYCLE_BIN_KEY]: [],
            [OVERDUE_KEY]: [],
        },
    },
});

// you need to initialize store first after creating useAppStore
// with the instance of real store for using in entities methods and with the logger for store
initTasksStore(useAppStore, storeLogger);

extending domain store logic in use cases

import { addTask, createTask } from '@budarin/tasks-domain';

function storeAddTask(task: unknown): ResultOrError<Task> {
    const addResult = addTask(task);

    if (addResult.error) {
        return addResult;
    }

    const state = useAppStore.getState();
    // additional logic for managing filters & categories
    {...}
}

// using extended logic
storeAddTask(createTask({
    taskId: 1,
    title: 'TaskTitle',
    priorityId: 1,
    deleted: false,
    completed: false,
}))

License

MIT

1.0.66

6 days ago

1.0.65

6 days ago

1.0.64

6 days ago

1.0.69

6 days ago

1.0.68

6 days ago

1.0.67

6 days ago

1.0.71

6 days ago

1.0.70

6 days ago

1.0.63

27 days ago

1.0.62

1 month ago

1.0.61

1 month ago

1.0.60

1 month ago

1.0.59

2 months ago

1.0.55

2 months ago

1.0.54

2 months ago

1.0.58

2 months ago

1.0.57

2 months ago

1.0.56

2 months ago

1.0.49

2 months ago

1.0.51

2 months ago

1.0.50

2 months ago

1.0.53

2 months ago

1.0.52

2 months ago

1.0.48

2 months ago

1.0.47

2 months ago

1.0.46

2 months ago

1.0.45

2 months ago

1.0.44

2 months ago

1.0.43

3 months ago

1.0.42

3 months ago

1.0.39

3 months ago

1.0.40

3 months ago

1.0.38

4 months ago

1.0.37

4 months ago

1.0.36

4 months ago

1.0.35

4 months ago

1.0.34

4 months ago

1.0.29

5 months ago

1.0.28

5 months ago

1.0.33

5 months ago

1.0.32

5 months ago

1.0.31

5 months ago

1.0.30

5 months ago

1.0.26

5 months ago

1.0.25

5 months ago

1.0.27

5 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.22

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago