TypeScript有委托或jquery 事件委托实现么?如何实现AOP?

Atom TypeScript
JavaScript developers can now just open a .ts file and start hacking away like they are used to. No grunt no Visual Studio. Just pure coding.
Installation
apm install atom-typescript (apm needs git in your path)
Fire up atom. Open a TypeScript file. Potentially wait for further installs (just apm install linter if its not there already).
Additional Notes: .
Featured on the TypeScript home page under tools
"I was shocked at how good it felt to poke around on the compiler with it."
"And guess what, it worked perfectly. Like everything else! Faster than Visual Studio!"
"It's a thing of beauty - they had me at 'Type information on hover'. Discovering
tsconfig.json support as well was just an enormous bonus."
"This may be your best option for editing TypeScript at the moment - very nice!"
Autocomplete
Live error analysis
Type information on hover
Compile on save
Project Context Support (tsconfig.json)
Project Build Support
package.json Support
React Support
Format code (configurable to be on save)
Goto Declaration
Find References
Block comment and uncomment
Goto history (goto next/previous error in open files, goto next/previous build)
Auto indent for new lines
TypeScript context menu
Symbols in Project
Symbols in File
Semantic View
Rename refactoring
Toggle Breakpoint
Common Snippets
import / /// &reference relative path resolution
Output Toggle
AST visualizer
Dependency View
Located online :
Feature Details
Auto Complete
Internally using AutoComplete+. Just start typing and hints will show up. Or you can explicitly trigger it using ctrl+space or cmd+space. Press tab to make a selection.
Type information on hover
Just hover
Compile on save
TypeScript files will be compiled on save automatically. Different notifications are given if emit was successful or not. If you need to disable this feature, add "compileOnSave": false in your .
Project Support
Supported via
which is going to be the defacto Project file format for the next versions of TypeScript.
It also supports filesGlob which will expand files for you based on minmatch|glob|regex (similar to grunt).
Project Build Support
Shortcut: F6. If there are any errors they are shown as well.
NPM Module Support
We have a sample NPM module :
(trick : in tsconfig have "declaration" : true an in package.json have a typings field pointing to the main file) and its usage is demoed in .
React Support
Configuration tips
Covered here :
Html to TSX
Format Code
Shortcut : ctrl+alt+l or cmd+alt+l. Will format just the selection if you have something selected otherwise it will format the entire file.
Format on save is covered
Go to Declaration
Shortcut : F12. Will open the first declaration of the said item for now. (Note: some people call it Go to Definition)
Find References
Shortcut shift+F12. Also called find usages.
Block Comment and Uncomment
ctrl+/ or cmd+/. Does a block comment / uncomment of code.
Go to Next / Go to Previous
f8 and shift+f8 respectively. This will go to next/previous errors in open files OR build error OR references based on which tab you have selected.
Context menu
Quickly toggle the TypeScript panel OR select active TypeScript panel tab and other stuff using the context menu. ctrl+; or cmd+;.
Symbols View
Integrates with atom's symbols view (ctrl+r or cmd+r) to provide you with a list of searchable symbols in the current file.
Semantic View
A bird's eye view of the current file. Use command toggle semantic view. The view updates while you edit the code. You can also click to jump to any portion of the file.
Project Symbols View
Also called Go To Type in other IDEs. Integrates with atom's project level symbols (ctrl+shift+r or cmd+shift+r) to provide you with a list of searchable symbols in the entire typescript project.
Refactoring
f2 to initiate rename. enter to commit and esc to cancel.
Press the TypeScript: Quick Fix shortcut alt+enter at an error location to trigger quick fixes. Select the quick fix you want and press enter to commit e.g
Add class members
More Quick fixes
We are actively adding quick fixes so .
Toggle Breakpoint
Use command TypeScript: Toggle Breakpoint shortcut f9:
tsconfig validation
We will validate it and help you to fix it :)
Relative Paths
Relative paths have traditionally been a pain, not anymore. Use import or ref and press tab to trigger snippet.
Note that within the path string you get autocomplete (ctrl+space/cmd+space) for all the files in the project by filename (works for both ref and import).
Output Toggle
ctrl+shift+m to toggle the output compiled JS file for a give TypeScript file. The keyboard shortcut is consistent with atom's markdown preview.
AST Visualizer
Command : Typescript: Ast. Useful when authoring new features.
Also command : TypeScript: Ast Full that includes the trivia (punctuation, comments etc. received from ts.Node.getChildren()) as well.
Dependency View
Command : Typescript: Dependency View. A dependency viewer for insight into the project if you use external modules. You can zoom, pan, drag points around and hover over nodes. ()
We try to keep as much of the stuff in sync while you edit code. However in dire circumstances:
a soft sync is done when you save a file ctrl+s and we will completely reprocess the active file. This might not fix stuff if the error is because of some other file on the file system.
ctrl+' or cmd+' : If you deleted files in the background or renamed them or jumped git branches or something weird just happened then sync. No need to restart your IDE :).
Contributing
for curiosity. We work hard to keep the code as approachable as possible and are highly keen on helping you help us.
Breaking changes .Posts - 270,
Articles - 0,
Comments - 1998
08:46 by 破狼, ... 阅读,
在上篇中,我们讲述了CoffeeScript这门小巧的语言,摒弃JavaScript中糟粕(&坑&)部分,并将JavaScript中精粹部分发挥到淋淋尽致。虽然笔者更喜欢ES6 + Babel或者TypeScript这类鲜明特性的JavaScript语法。但是CoffeeScript也不失为一门不错的JavaScript扩展语言,特别在Ruby社区仍然是一个很好的选择。
在本节中,我们将会利用CoffeeScript来模拟Python中的装潢器实现。Python的装潢器是属于一类来自于语言层次的AOP实现。AOP是Aspect-Oriented Programming的缩写,意为:面向切面编程。通过编译时(Compile)植入代码、运行期(Runtime)动态代理、以及框架提供管道式执行等策略实现程序通用功能与业务模块的分离,统一处理、维护的一种解耦设计。AOP是OOP的延续,是软件开发中的一个热点,也是很多服务端框架(如Java世界的Spring)中的核心内容之一,是函数式编程的一种衍生范型。 利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可复用性,同时提高开发效率。 AOP实用的场景主要有:权限控制、日志模块、事务处理、性能统计、异常处理等独立、通用的非业务模块。关于更多的AOP资料请参考。
在Python中的装潢器也是一个普通的函数,我们只需要使用@符号将方法标注在另一个方法签名上就能实现对被标注方法的装潢。这也是Python这门函数式语言中高阶函数的运用。被装潢的方法将会被传入装潢函数中,被装潢包裹以实现方法的拦截。
Python中的装潢器如下:
def deco(func):
def _deco(*args, **kwargs):
print("before %s called." % func.__name__)
ret = func(*args, **kwargs)
after %s called. result: %s" % (func.__name__, ret))
return ret
return _deco
def myfunc(a, b):
print(" myfunc(%s,%s) called." % (a, b))
return a+b
这里的装潢器deco,将会包裹myfunc方法,实现调用前后的日志信息拦截。
在CoffeeScript中,我们如何实现呢?在CoffeeScript并没有真正的装潢器这一特性,但它存在高阶函数,可以如下包裹:
log(myfunc)
在CoffeeScript中,我们也可以简化去掉方法()符号:
log myfunc
如果我们再像Python一样强制加上@符号,并将log函数放在方法声明右边,则似乎就有点接近Python的装潢器:
f = @log (a, b) -& a + b
不知作为读者的你,是否也有点装潢的感觉呢?不用着急,我们在来看一个完整的demo示例:
See the Pen
by green () on .
这里利用了高阶函数的log函数来包装我们的自定义函数。其实这只是高阶函数的运用,如果这门语法也能省略掉方法调用的(),则完全也可以做到如上实现。希望作为读者的你,到这里已经明白的在函数式中高阶函数的魅力,以及其重要性。javascript - TypeScript Web-Based IDE - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Given the fact that TypeScript is Open Source, is
also available as a tool that can be downloaded anywhere?
I'm developing a web application in which the client can write a user-defined expression (with user-defined variables and predefined methods) which is evaluated, compiled and used at runtime on the server using C# .Net. Using TypeScript and its wonderful web-based editor's features like syntax or error highlighting, code completion, method signature suggestion, etc,
saves me lots of trouble in the user interface.
So is this editor also part of TypeScript? If not, is there any other open source solutions with similar capabilities?
9,21793574
There is a discussion on the TypeScript Codeplex site that suggests a similar editor that is available under an MIT license that may help:
As far as I am aware the Playground editor source isn't public (yet).
94.4k21177240
There are some web IDEs with support of TypeScript, namely:
(choose TypeScript from dropdown)
If you think about making a new one, you could base on one of my 2 projects:)
11.4k64158
There is an implementation of it which is open source:
there is goormIDE which is also cloud IDE
this is open source or service version
if you use node.js, just type this command
$ npm install goorm -g
provides a VM with Root so you can install whatever tools you need, and in this case, TypeScript via npm install -g typescript.
VM Domain and Apache is included, so previewing your work in your browser is also easy :)
1,11731629
For very simple stuff you can try out
Your typescript files will be converted to a js file on the fly and your site will be hosted for free on Google Drive.
I am using CATS, and I really like it because of two things:
The IDE is not so bad. It does it job done, and once you practice with it, you'll like it!
It's portable
THe last is the feature I like the most, because I don't have to install anything (at least, under Windows), and you don't need Visual Studio (it's around 9 Gb and two hours installing).
The TypeScript Playground is a nice editor, but if you need to test small scripts, or want to try something that can be done only in one file!
The editor used on the playground is informally known as Monaco and it's used in .
UPDATE 11.22.2015:
Visual Studio Code is now open source, which means we have access to the source of the Monaco Editor. I think this should now give us the ability to use the Monaco Editor in a browser, I'm
to my question in the VS Code repostiroy.
The 'editor' (the thing that renders the code with syntax highlighting, line numbers, etc..) part of Visual Studio Code is Microsoft's Monaco editor. It is the same editor used for OneDrive, Windows Azure, TypeScript Playground, and Visual Studio Online. I have yet to find any real documentation on this editor from Microsoft but there are some articles about it around the web.
Read more about Visual Studio Code .
I don't think so. According to , VisualStudio is your best bet. It mentions Visual Studio Express, so event though it's not open source, you would not incur any costs.
4,49033261
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled怎么回答面试官:你对Spring的理解?
小菜菜,刚想参加工作,求大牛给予指点,他日菜菜必有重谢
按时间排序
反问面试官用过spring-brother吗。
就我了解到的关于spring的东西并不多,现在还是停留在会用的阶段,但是我觉得spring框架就是一个容器,这个容器最主要的作用就是创建对象,以前我们创建对象时通过new关键字,现在不需要这么麻烦了,只需要找到这个容器就可以找到你需要的对象,其实就是一个factory,这个工厂可以提供很多我们需要的对象,我们只需要知道对象对应的名字就行了,至于其他关于spring更多高深的东西就不是很清楚了,如果各位有什么好的见解可以分享一下互相学习一下
一份写好的配置文件和组件顶过会议上千言万语的沟通,便是spring最大的优点。。
现在为了提高开发效率,很多公司都在用spring,所以这个问题一般来说都是考察候选人对spring的理解程度,考虑能不能很好的融入团队。另外不用spring的也问,就是看候选人的学习深度了。标准答案ioc和aop没什么难的,关键在后面的问题:对于ioc或者aop,候选人认为他们好在哪里,为什么好。
读 expert one on one j2ee design and development 这本书.
首先Spring是一个大的概念,Spring从最开始的一个Library到现在一个系列,其中最主要的包括Spring Framework, Spring Data, Spring Security, Spring Batch等等,以及快速框架Spring Boot,其中最重要的项目是Spring Framework,这个项目包括了IoC, AOP, MVC以及Testing。第一个需要明白的是Spring的核心思想是什么?Spring整个系列的最最核心的概念当属IoC, AOP,什么是IoC和AOP就不展开了,简而言之,将对象创建过程的职责赋予容器,通过容器管理对象的生老病死, 将对象创建过程从编译时延期到运行时,即通过配置进行加载,这样一来就解决了不用编译后期选择具体实现,其实就是面向对象的核心理念,针对接口编程。IoC开始就是个factory加上依赖管理罢了,这样一来,一个系统的创建过程就从原先的new改为配置组装,内部通过注入解决了依赖关系,只要满足接口协议即插即用。通过IoC, AOP事实上形成了一个套路,通过这个套路完成了系统的整合。所以Spring并没有说自己写一个ORM,而是用统一的套路完成了多个ORM的集成,这也是Spring越做越大的基础,慢慢就形成了Spring Way,其实这个才是Spring最有价值的地方。第二当然就是一些实践,其实主流问的大概也就几个方向,用的最多的应该就是Spring MVC, Spring Data,
Spring Security和Spring Boot这几块吧,因为毕竟这是实践性内容,很多时候都是show me the code,之前学习过程写过一个sample,基本全是标准Spring Way,你可以拿去参考一下,Spring BootSpring MVCSpring SecurityGradleFreemarkerWebJarsSpring Data JPAMysqlWechatReactTypeScriptwebpackRedisMay it helps.
如果我是面试官,我问的这个问题其实是想让你系统的介绍一下你所掌握的Spring的知识和应用情况。1. Spring是什么?讲一下Spring的由来、思想、特性2. Spring都有哪些产品组成?每个产品的作用、特点、使用场景?3. 我在工作中用到了Spring的哪些产品、哪些特性?怎么用的?为什么用?因为一般问出这个问题的面试官都问不出特别高深的问题,如果你能给他系统的科普一下Spring知识,会有大大的加分!hahahahah
已有帐号?
无法登录?
社交帐号登录

我要回帖

更多关于 spring aop实现原理 的文章

 

随机推荐