Skip to content
This repository has been archived by the owner on Jan 12, 2020. It is now read-only.

Commit

Permalink
Migrate to module syntax for custom manager APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Sep 18, 2018
1 parent 06d0c26 commit 53d5cd8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions addon/component-managers/sparkles.ts
@@ -1,7 +1,7 @@
import Ember from 'ember';
import { set } from '@ember/object';
import { getOwner, setOwner } from '@ember/application';
import ApplicationInstance from '@ember/application/instance';
import { capabilities } from '@ember/component';
import SparklesComponent from 'sparkles-component';

export interface ComponentManagerArgs {
Expand All @@ -18,7 +18,7 @@ export default class SparklesComponentManager {
capabilities: any;
constructor(owner: ApplicationInstance) {
setOwner(this, owner);
this.capabilities = Ember._componentManagerCapabilities('3.4', {
this.capabilities = capabilities('3.4', {
destructor: true,
asyncLifecycleCallbacks: true,
});
Expand Down
5 changes: 2 additions & 3 deletions addon/index.ts
@@ -1,4 +1,4 @@
import Ember from 'ember';
import { setComponentManager } from '@ember/component';

class SparklesComponent<T = object> {
constructor(public args: T) {}
Expand All @@ -9,8 +9,7 @@ class SparklesComponent<T = object> {
// didRender() {}
destroy() {}
}
// eslint-disable-next-line ember/new-module-imports
Ember._setComponentManager('sparkles', SparklesComponent);
setComponentManager('sparkles', SparklesComponent);

export default SparklesComponent;

Expand Down
7 changes: 7 additions & 0 deletions types/@ember/component.d.ts
@@ -0,0 +1,7 @@
declare module '@ember/component' {
export function setComponentManager<T>(managerId: string, baseClass: T): T;
export function capabilities(version: string, opts?: {
destructor?: boolean;
asyncLifecycleCallbacks?: boolean;
}): any;
}
5 changes: 0 additions & 5 deletions types/ember/index.d.ts
Expand Up @@ -4,11 +4,6 @@ declare module 'ember' {
interface _RegistryProxyMixin {
register(fullName: string, factory: any, options?: { singleton?: boolean, instantiate?: boolean }): any;
}
function _setComponentManager<T>(managerId: string, baseClass: T): T;
function _componentManagerCapabilities(version: string, opts?: {
destructor?: boolean;
asyncLifecycleCallbacks?: boolean;
}): any;

function notifyPropertyChange(target: object, key: string): void;
function addObserver<T>(target: T, dependentKey: string, instance: any, notifyMethod: () => void): T;
Expand Down

0 comments on commit 53d5cd8

Please sign in to comment.