Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下,什样将composer的嵌入到系统中实现单例 #113

Open
gmplato opened this issue Aug 7, 2020 · 2 comments
Open

请教一下,什样将composer的嵌入到系统中实现单例 #113

gmplato opened this issue Aug 7, 2020 · 2 comments

Comments

@gmplato
Copy link

gmplato commented Aug 7, 2020

老师,我想将composer的类库实现为单例,像DAO一样,有什么思路实现?

@gmplato
Copy link
Author

gmplato commented Aug 7, 2020

尝试过参考DAO模仿了一下,但不不成功。

@billge1205
Copy link
Collaborator

单例比较简单的实现方式就是建一个 静态对象(static)
然后通过一个function来判断该静态对象是否已经存在,如果已经存在则直接返回该对象,否者新建后返回

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants