Skip to content

Commit

Permalink
chore!: support removal of once from Function prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzkiy committed Dec 25, 2024
1 parent 4e889d4 commit e2d0101
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Changelog
_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.172 (2024-12-25)

#### :boom: Breaking Change

* Updated `@v4fire/core` to version `4.0.0-alpha.54` with removal of `once` from `Function` prototype

## v4.0.0-beta.171 (2024-12-23)

#### :house: Internal
Expand Down
4 changes: 2 additions & 2 deletions src/components/directives/bind-with/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

import type { EventEmitterLike, PromiseLikeP } from 'core/async';
import type { EventEmitterLikeP, PromiseLikeP } from 'core/async';

import type { DirectiveBinding } from 'core/component/engines';
import type { WatchOptions } from 'core/component/interface';
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface EventListener<A extends any[]> extends Handle<A> {
/**
* An event emitter to listen
*/
emitter?: EventEmitterLike | EventEmitterLike['on'];
emitter?: EventEmitterLikeP;

/**
* The event name to listen for, or a list of such events
Expand Down
1 change: 1 addition & 0 deletions src/components/directives/bind-with/test/unit/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test.describe('components/directives/bind-with', () => {
const el = await renderDirective(page, {
emitter: (event: string, listener: AnyFunction) => {
document.body.addEventListener(event, listener);
return undefined;
},

on: 'testEvent'
Expand Down
2 changes: 1 addition & 1 deletion src/components/super/i-block/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export default abstract class iBlockBase extends iBlockFriends {
// eslint-disable-next-line prefer-const
unwatch: Nullable<Function>;

const emitter: Function = (_: any, wrappedHandler: RawWatchHandler<typeof that, T>) => {
const emitter = (_: any, wrappedHandler: RawWatchHandler<typeof that, T>) => {
wrappedHandler['originalLength'] = handler['originalLength'] ?? handler.length;
handler = wrappedHandler;

Expand Down
2 changes: 1 addition & 1 deletion src/core/component/engines/vue3/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function getComponent(meta: ComponentMeta): ComponentOptions<typeof Compo
unsafe.$vueWatch = this.$watch.bind(this);
init.beforeDataCreateState(ctx);

const emitter: Function = (_: unknown, handler: WatchHandler) => {
const emitter = (_: unknown, handler: WatchHandler) => {
// eslint-disable-next-line @v4fire/unbound-method
const {unwatch} = watch(unsafe.$fields, {deep: true, immediate: true}, handler);
return unwatch;
Expand Down
7 changes: 4 additions & 3 deletions src/core/component/init/states/before-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Async from 'core/async';

import * as gc from 'core/component/gc';
import watch from 'core/object/watch';
import { once } from 'core/functools';

import { V4_COMPONENT } from 'core/component/const';
import { getComponentContext } from 'core/component/context';
Expand Down Expand Up @@ -121,7 +122,7 @@ export function beforeCreateState(

let fn = () => ('getRoot' in ctx ? ctx.getRoot?.() : null) ?? ctx.$root;

fn = fn.once();
fn = once(fn);

Object.defineProperty(ctx, $getRoot, {
configurable: true,
Expand Down Expand Up @@ -163,7 +164,7 @@ export function beforeCreateState(
return targetCtx[$getParent];
}

let fn: CanUndef<Function>;
let fn: CanUndef<AnyFunction>;

if (restArgs != null) {
// VNODE
Expand All @@ -179,7 +180,7 @@ export function beforeCreateState(
fn = () => ctx;
}

fn = fn.once();
fn = once(fn);

Object.defineProperty(targetCtx, $getParent, {
configurable: true,
Expand Down
3 changes: 2 additions & 1 deletion src/core/init/dependencies/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

import { once } from 'core/functools';
import type { DependencyFn, Dependency } from 'core/init/dependencies/interface';

/**
Expand Down Expand Up @@ -137,7 +138,7 @@ export function* createDependencyIterator(
wait: expandedWait
};

expandedDependency.fn = expandedDependency.fn.once();
expandedDependency.fn = once(expandedDependency.fn);
expandedDependencies.set(dependency, expandedDependency);

return expandedDependency;
Expand Down

0 comments on commit e2d0101

Please sign in to comment.