Gathering detailed insights and metrics for redux-data-service
Gathering detailed insights and metrics for redux-data-service
Gathering detailed insights and metrics for redux-data-service
Gathering detailed insights and metrics for redux-data-service
redux-data-service-react
[](https://circleci.com/gh/Rediker-Software/redux-data-service-react)
redux-service-demo
A simple React UI for testing Redux-based data services
redux-service-util
Utilities for building Redux data services
@superdata/business-data-service
前端基础数据服务。<br /> 用于对接基础模块的数据。<br /> 提供用户认证、角色权限、功能模块、字典、系统配置、埋点日志、消息管理等基础数据服务支持。<br /> 支持下载数据保存到不同数据源(localStorage、indexedDB、redux、mobx)的策略。<br /> 该服务仅依赖外部接口、数据管理器,不依赖任何UI组件库。<br />
Connect seamlessly to any API using first class Models, customizable serialization, validation, dependency injection and TypeScript type-safety
npm install redux-data-service
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
145 Commits
3 Forks
13 Watchers
6 Branches
7 Contributors
Updated on Jan 28, 2023
Latest Version
0.3.5
Package Id
redux-data-service@0.3.5
Unpacked Size
241.70 kB
Size
42.20 kB
File Count
223
NPM Version
6.5.0
Node Version
11.8.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
13
26
A Redux library to seamlessly connect to any API using first-class models created from true TypeScript classes, with support for customizable serialization, validation, and dependency injection.
TypeScript
classes:1// student/model.ts 2import { attr, required, Model, EmailField, NumberField, StringField } from "redux-data-service"; 3 4export class Student extends Model { 5 public readonly string serviceName = "student"; 6 7 @required() 8 @attr(StringField) 9 public string firstName; 10 11 @attr(NumberField) 12 public string age; 13 14 @attr(EmailField) 15 public string email; 16}
belongsTo
and hasMany
relationships to other models which are lazy-loaded when they are requested.1import { Student } from "./student"; 2 3const student = new Student({ id: "123" }); 4 5student.firstName = "Jessica"; 6student.age = 9; 7student.email = "jess@example.com";
1{ type: "student/SET_FIELD", payload: { id: "123", fieldName: "firstName", value: "Jessica" } } 2{ type: "student/SET_FIELD", payload: { id: "123", fieldName: "age", value: 9 } } 3{ type: "student/SET_FIELD", payload: { id: "123", fieldName: "email", value: "jess@example.com" } }
Commit pending changes to the model's corresponding API end-point:
1student.save();
Calling the save
method validates the model and dispatches an action to an underlying redux-observable epic:
1{ type: "student/UPDATE_RECORD", payload: { id: "123" } }
The epic will then:
POST
or a PUT
to the API to create or update the model (using the default API adapter):1PUT api/students/123 2{"id": "123", "firstName": "Jessica", "age": 9, "email": "jess@example.com"}
Although the above example uses the default serializer and API adapter for connecting to a REST API, any ISerializer or IAdapter may be used to connect to any API.
1import * as React from "react"; 2import { withModelQuery } from "redux-data-service-react"; 3 4export const StudentList = withModelQuery({ modelName: "student" })( 5 ({ items }) => ( 6 <ul> 7 {items.map(student => ( 8 <li key={student.id}>{student.name}, age {student.age}, email {student.email}</li> 9 ))} 10 </ul> 11 ) 12);
Apollo-like syntax is also supported:
1import * as React from "react"; 2import { Query } from "redux-data-service-react"; 3 4export const StudentList = ( 5 <Query modelName="student"> 6 {({ items }) => ( 7 <ul> 8 {items.map(student => ( 9 <li key={student.id}>{student.name}, age {student.age}, email {student.email}</li> 10 ))} 11 </ul> 12 )} 13 </Query> 14);
Simply use your component as you normally would and it will automatically query the API when the component mounts:
1<StudentList />
Additional query params may be specified:
1<StudentList queryParams={{ page: 1, name: "Jess" }}/>
You may also provide an iterable list of models to render instead of querying the API:
1<StudentList items={students}/>
1import * as React from "react"; 2import { withNewModel, ModelForm, ModelField } from "redux-data-service-react"; 3 4const Input = (props) => <input {...props />; 5 6export const StudentForm = withNewModel("student")( 7 ({ student, ...props }) => ( 8 <ModelForm model={student} {...props}> 9 <ModelField name="firstName" component={Input}/> 10 <ModelField name="age" type="number" component={Input}/> 11 <ModelField name="email" type="email" component={Input}/> 12 <Input type="submit" value="Save" /> 13 </ModelForm> 14 ) 15);
The above form can be used for creating or editing a student
model:
<StudentForm />
<StudentForm studentId="123"/>
or <StudentForm student={student}/>
When the form is submitted it will:
1import * as React from "react"; 2import { withModel } from "redux-data-service-react"; 3 4export const StudentDetail = withModel("student")( 5 ({ student }) => ( 6 <section> 7 <h1>{student.name}</h1> 8 <strong>age:</strong> {student.age} 9 <em>{student.email}</em> 10 </section> 11 ) 12);
The above component, given a model id, will load and subscribe to the requested model.
Simply pass the id from the route into the above component, for example:
<Route
path="/students/:studentId"
render={(props) => <StudentDetail studentId={props.match.params.studentId}/>}
/>
Before we can use the Student model defined above, we must wire it into Redux!
DataService
class for each modelThe DataService
class provides a layer of abstraction around Redux to create a unidirectional, immutable architecture without the pain!
1// student/service.ts 2import { DataService } from "redux-data-service"; 3import { Student } from "./Student"; 4 5export class StudentService extends DataService { 6 public readonly name = "student"; 7 public readonly ModelClass = Student; 8}
redux-data-service
and create your Redux
data storeAdd each of your DataService classes to the configure
function to enable dependency injection and create the Redux store
redux-data-service
to globally override any default functionality as needed1import { configure } from "redux-data-service"; 2import { StudentService } from "./student/service.ts"; 3 4export const store = configure({ 5 modules: { 6 student: StudentService 7 } 8});
Please Read the docs for more detailed information.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 11/30 approved changesets -- score normalized to 3
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
132 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More