Skip to content

Commit 897e1ef

Browse files
committed
revert: merge commit
1 parent 13cade3 commit 897e1ef

File tree

7 files changed

+41
-104
lines changed

7 files changed

+41
-104
lines changed

docs/calliope/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ The `getKeyName` method returns the [primaryKey](#primarykey) of the model.
123123

124124
The `getName` method expected to return the current class' name. For example in a class called `User` it should return `'User'`.
125125

126-
*Note: This is essential to add to every model as this is used throughout the framework.*
126+
***Note: This is essential to add to every model as this is used throughout the framework.***
127127
::: danger
128128
This value cannot be `this.constructor.name` **if** you're minifying your code or in the minification options you haven't turned off the class rename or equivalent option.
129129
:::

docs/cookbook.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ interface PaginatedModels<T extends Model> {
247247
}
248248

249249
export async function paginateModels<T extends Model>(builder: T, page = 1, limit = 25): Promise<PaginatedModels<T>> {
250-
const response = await builder.limit(limit).page(page).call<MyJsonApiResponse>('get');
250+
const response = await builder.clone().limit(limit).page(page).call<MyJsonApiResponse>('get');
251251
const modelCollection = new ModelCollection<T>(response!.data.map(attributes => builder.new(attributes)));
252252
// or some other custom logic where the response `meta` and `links` or other keys (if any) are taken into account
253253

docs/getting-started/readme.md

-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ const excellentStudentNames = students
1313
.pluck('name');
1414
```
1515

16-
```ts
17-
import User from '@models/User';
18-
19-
const students = await User.where('is_student', true).with('grades').get();
20-
21-
const excellentStudentNames = students
22-
.filter(student => student.grades.average('value') > 4)
23-
.pluck('name');
24-
```
25-
2616
## What does it solve?
2717
There are number of solutions out there for fetching data and working with the response. However not all of these might be as scalable as one would hope. With state management, you might have a getter for users, but those users include all users, meaning for a custom collection you would need a new getter method. An on-demand ajax request written specifically to solve a single issue, while it is simple to do, it quickly gets repetitive and hard to maintain. [Upfront](./installation.md) solves the above by creating abstraction over the data in a unified api. Just like the above examples it can be used to fetch data on demand or be complimentary to state management libraries.
2818

docs/helpers/event-emitter.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The `on` method sets up the listener for an event. It receives two arguments, th
1616
import { EventEmitter } from '@upfrontjs/framework';
1717
import type { MyEvents } from '../types';
1818

19-
const emitter = EventEmitter.getInstance<>();
19+
const emitter = EventEmitter.getInstance<MyEvents>();
2020
emitter.on('myEvent', num => num);
2121
emitter.emit('myEvent', 2);
2222
```
@@ -29,7 +29,7 @@ The `once` method works the same way as the [on](#on) method except once the cal
2929
import { EventEmitter } from '@upfrontjs/framework';
3030
import type { MyEvents } from '../types';
3131

32-
const emitter = EventEmitter.getInstance<>();
32+
const emitter = EventEmitter.getInstance<MyEvents>();
3333
emitter.once('myEvent', num => console.log(num));
3434
emitter.emit('myEvent', 1); // 1 logged out to the console
3535
emitter.emit('myEvent', 1); // nothing happens
@@ -42,7 +42,7 @@ The `prependListener` method works the same way as the [on](#on) method except t
4242
import { EventEmitter } from '@upfrontjs/framework';
4343
import type { MyEvents } from '../types';
4444

45-
const emitter = EventEmitter.getInstance<>();
45+
const emitter = EventEmitter.getInstance<MyEvents>();
4646
emitter.on('myEvent', num => console.log(num));
4747
emitter.prependListener('myEvent', num => console.log('first log: ', num));
4848
emitter.emit('myEvent', 1); // logged out 'first log: 1', then '1'

package-lock.json

+33-86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@upfrontjs/framework",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Data handling framework complementary to backend model systems.",
55
"main": "index.min.js",
66
"module": "index.es.min.js",

src/Calliope/Model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export default class Model extends SoftDeletes implements HasFactory {
6565
*
6666
* @return {this}
6767
*/
68-
public new(attributes?: Attributes | Attributes<this>): this {
69-
return new (this.constructor as new (attributes?: Attributes | Attributes<this>) => this)(attributes);
68+
public new(attributes?: Attributes<this> | Model): this {
69+
return new (this.constructor as new (attributes?: Attributes<this> | Model) => this)(attributes);
7070
}
7171

7272
/**

0 commit comments

Comments
 (0)